Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with converting an NSImage to grayscale




[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: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.