NSBitmapImageRep
NSBitmapImageRep
- Subject: NSBitmapImageRep
- From: John Stiles <email@hidden>
- Date: Wed, 20 Jun 2007 14:58:23 -0700
I'm using the following call to generate an NSBitmapImageRep from 32-
bit data I've loaded from an external source:
NSBitmapImageRep * rep = [[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:&imagePtr
pixelsWide:inImage.width
pixelsHigh:inImage.height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
b
itmapFormat:NSBitmapFormat(NSAlphaFirstBitmapFormat |
NSAlphaNonpremultipliedBitmapFormat)
bytesPerRow:4 * inImage.width
b
itsPerPixel:32] autorelease];
There's one problem—the data I'm getting seems to be backwards from
what the function expects! It looks like ARGB if you load it into a
32-bit register on an Intel machine, but if you look at the memory
from a "big-endian" perspective, it's really BGRA.
Is there any way to tell -initWithBitmapDataPlanes::::: that the
color channels are in reverse order? I couldn't see any option for
this in the API reference but it seems like a fairly common issue.
(OpenGL, for instance, has an incredible variety of supported image
types and is smart enough to convert from what you have to what the
card needs.)
At the end of the day I just need an NSImage, so if there is another
API better suited for the talk that's supported on 10.4.x, I'd be
interested to learn more.
I do have a simple workaround—just byteswap all the image data by
hand before calling this method. This works fine and it was only a
few lines of code, so I can use that if necessary. I'd just like to
know if there is a better way._______________________________________________
Cocoa-dev mailing list (email@hidden)
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