• 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
Re: Problem with converting an NSImage to grayscale
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Prev by Date: RTFD file corruption
  • Next by Date: Re: RTFD file corruption
  • Previous by thread: Re: Problem with converting an NSImage to grayscale
  • Next by thread: multiple objects in my view
  • Index(es):
    • Date
    • Thread