Converting image to 8-bit gray?
Converting image to 8-bit gray?
- Subject: Converting image to 8-bit gray?
- From: Jonathan Hendry <email@hidden>
- Date: Thu, 21 Jun 2001 17:35:48 -0500
Howdy,
I need to load color image files (TIFF, jpg, etc),
and convert them to 8-bit grayscale.
I've got it sort of working, but it's inconsistent and
I'm not sure why.
Currently, what I'm doing (and it's probably not
the best way) is creating an NSImage with the file,
grabbing the NSImage's first ImageRep and setting its
colorSpaceName to NSCalibratedWhiteColorSpace, then
compositing that NSImage into a second NSImage of
the same size.
Sometimes, this works, and I get a grayscale version of
the original. Other times, this doesn't work, and I
end up with a color image. Some jpeg files work, others
don't. I have a tiff that retains its color.
Is there a better, more consistent way of doing this?
Thanks,
Jon