Hi,
I have to read all the RGBA values of every pixel of an image on the disk,
as tif, png, jpgŠ I read the imageRep with imageRepWithContentsOfFile and
get the RGBA values with "colorAtX: y:" It works quite well with png images
with "non alpha premultiplied" bitmap format. In this case I get a
bitsPerPixel = 32.
But if I save the same image with Photoshop as TIF, I get an "alpha
premultiplied" bitmap format and a bitsPerPixel = 24. But worst of all, all
the alpha values are 1.0, while some of them is for sure 0.5. So I can't
even calculate the original non multiplied RGB values.

My question is: how can I get the true original RGBA pixels values of any
image? Actually I do:

imageRep = [NSBitmapImageRep imageRepWithContentsOfFile:filePath];
texWidth = [imageRep pixelsWide];
texHeight = [imageRep pixelsHigh];

for(y = 0; y < texHeight; y++){
    for(x = 0; x < texWidth; x++){
        NSColor    *pixelColor = [imageRep colorAtX:x y:y];
        NSColor    *rgbColor = [pixelColor colorUsingColorSpace:
                [NSColorSpace deviceRGBColorSpace]];
        [rgbColor getRed:
                &rgba[0] green:&rgba[1] blue:&rgba[2] alpha:&rgba[3]];
    }
}


Regards
-- Leonardo


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to