I need to get at the RGB pixel data of an image (with will be a jpg or png, tho probably a jpg)
NSImage * image = [NSImage imageNamed:@"colorTest"]; NSBitmapImageRep * imageRep = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]]; unsigned char * imageData = [imageRep bitmapData]; The docs say: "The NSImage class keeps a reference to any named images in a table until the image name is cleared. Consequently you do not need to retain the returned image object unless its name could be cleared. You can clear an image object from the table by passing nil to the setName: method of the corresponding NSImage object." So I am not sure if I should be using initWithContentsOfFile (the image file is in my app bundle). What needs to be released and retained in this case? If I release "image", does that also release "imageRep"? Basically I will open this file, read the pixel data and use it elsewhere so once I am done I need to release image and imageRep. Finally... In my testing I always get the data as RGB with no alpha padding (at least in the jpg case). How can I guarantee this? This is all a bit murkey for me yet as the current version of this code uses QuickTime and Gworld to get pixels from a jpg. Thanks, Trygve _______________________________________________ Cocoa-dev mailing list ([email protected]) 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 [EMAIL PROTECTED]
