| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Thanks! -Vance
Yes but that raises a question which is whether you'll be replacing meaningful information based only on color. Your image may contain sections the same color as clouds which are not meant to be replaced.
You may want to dig into pattern recognition, which is way off-topic.
Cheers,
Filipe
On 2008/01/30, at 17:27, Vance wrote:
I want to replace the pure black as well as the black underneath the areas of shaded white.
The image I have contains satellite image of clouds. So replacing only the pure black will not make it look right when placed on background other then black.
Does that mean I have to process even non-pure black regions myself as well?
Thanks! Vance
Filipe Varela wrote:If you only want to replace pure black, iterate thru every pixel in the bitmap looking for black (rgb channels same value = 0). Whenever you find such a pixel, change it's alpha value to whatever you need.
ie
unsigned char buffer = [rep bitmapData];
unsigned char pixel; //temp
for (h=0; h<height; h++) {
for (w=0;w<width;w++) {
pixel = buffer + (h * numBytesPerPixel * width) + w * numBytesPerPixel;
//channel index depends on image format, check the attributes
//attribs: (alpha first, alpha premultiplied, etc)
//assume (example) that img is rgba. (0=red 1=green 2=blue 3=alpha)
if(pixel[0]==0 && pixel[1]==0 && pixel[2]==0) // all black. set alpha to max
pixel[3] = 255;
}
}
Your image is now transparent or fully opaque.
Cheers,
Filipe
On 2008/01/30, at 17:07, Vance wrote:
Hi,
I have an NSImage (black and white) that I want to replace the black color with transparency.
I want it to be replaced in such a way, so even the shades of gray look correct when overlayed on top of another color, lets say blue.
What is the best way of do this?
Thanks. Vance _______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden
| References: | |
| >Named image for regular folder? (From: Jim Correia <email@hidden>) | |
| >Re: Named image for regular folder? (From: Ken Thomases <email@hidden>) | |
| >Re: Named image for regular folder? (From: Matt Gough <email@hidden>) | |
| >Set Alpha for an NSImage (From: Vance <email@hidden>) | |
| >Re: Set Alpha for an NSImage (From: Filipe Varela <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.