I'm working with 16-bit grayscale images, and for the most part I'm just 
manipulating bits within NSBitmapImageRep objects. However for convenience it 
would be nice to do some stuff with NSImages, particularly when rescaling and 
suchlike. The problem is that whenever I draw into such an NSImage it gets 
converted to 3x8 bit RGB. Is there a simple way I can force things to stay 
grayscale, or am I fighting a losing battle here. The code snippet I have looks 
like this:

NSImage *srcImage = [[NSImage alloc] initWithContentsOfFile:thePath];
NSImage *destImage = [srcImage copy];   // Attempt to "encourage" same 16-bit 
grayscale format as source
[destImage setSize:destSize];                   // Shrink dest image

// Draw image into a new image at reduced size
// This causes the result to be saved as a 3x8 bit RGB TIFF (which is not what 
I want!)
[destImage lockFocus];
[srcImage drawInRect:destRect fromRect:srcRect operation:NSCompositeCopy 
fraction:1.0];
[destImage unlockFocus];
[[destImage TIFFRepresentation] writeToFile:destFile atomically:NO];

Does anyone have any suggestions?
Thanks
Jonny_______________________________________________

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