• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Keeping grayscale image grayscale
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Keeping grayscale image grayscale


  • Subject: Keeping grayscale image grayscale
  • From: Jonathan Taylor <email@hidden>
  • Date: Mon, 10 Oct 2011 18:43:40 +0100

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 (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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Keeping grayscale image grayscale
      • From: Scott Ribe <email@hidden>
  • Prev by Date: Re: Give a menu keyboard focus – in code
  • Next by Date: Re: Sandboxing + NSSavePanel's accessoryView
  • Previous by thread: Re: NSTreeController with bindings and core data - still an issue?
  • Next by thread: Re: Keeping grayscale image grayscale
  • Index(es):
    • Date
    • Thread