Re: Problem with converting an NSImage to grayscale
Re: Problem with converting an NSImage to grayscale
- Subject: Re: Problem with converting an NSImage to grayscale
- From: Bill Monk <email@hidden>
- Date: Wed, 31 Aug 2005 08:09:13 -0600
[re-send for the archives; original posting inadvertently went out
with a Digest subject line]
On Aug 30, 2005, at 5:06 AM, Arik Devens wrote:
The code works on some images and not others, but I haven't been
able to
figure out why some work and some don't. For the ones that don't I
get a
totally skewed grayscale image...
NSBitmapImageRep *destImageRep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:nil
pixelsWide:widthInPixels
pixelsHigh:heightInPixels
bitsPerSample:8
samplesPerPixel:1
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSCalibratedWhiteColorSpace
bytesPerRow:0
bitsPerPixel:8];
Try changing bytesPerRow: from 0 to the actual calculated rowBytes
value.
The docs seem to say that passing 0 is OK, but in Tiger this seems
not to work anymore.
I've run across another sample which used initWithBitmapDataPlanes:
and which worked fine under Pather/Jaguar, but which exhibited
skewing and tearing of the image under Tiger. Passing the real # of
bytes per row fixed it.
Bill
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden