On 12 Mar '08, at 9:09 AM, Trygve Inda wrote:
NSImage * image = [NSImage imageNamed:@"colorTest"];NSBitmapImageRep * imageRep = [NSBitmapImageRep imageRepWithData: [imageTIFFRepresentation]];
That will work, I think, but it's sort of inefficient, since it requires encoding and decoding TIFF.
The quickest way would be to look at the NSImage's array of imageRepresentations and look for an NSBitmapImageRep of the right dimensions. Most types of images have one (the exceptions I can think of are PDF, icns and PICT.)
If that fails, you can create a new empty NSBitmapImageRep, lockFocus on it, draw the source image into it, and unlockFocus.
What needs to be released and retained in this case? If I release "image",does that also release "imageRep"?
In your code as give above, you didn't directly alloc or retain anything, so there's nothing to release. However, none of the objects are guaranteed to exist after the topmost autorelease pool exits. If you want to keep a long-term reference you'll need to retain that object. (If you want to keep using the raw pixel data, you need to retain its owner, the image-rep.)
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?
Then you definitely want to create your own NSBitmapImageRep — the init method will give you total control over the pixel format. Then you can lockFocus and draw whatever you want into it.
—Jens
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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 [EMAIL PROTECTED]