Re: Convert GWorldPtr into a NSImage
Re: Convert GWorldPtr into a NSImage
- Subject: Re: Convert GWorldPtr into a NSImage
- From: Michael Vannorsdel <email@hidden>
- Date: Thu, 8 Jan 2009 04:57:09 -0700
Have a look at vImagePermuteChannels_ARGB8888 in the Accelerate
framework. Should be the fastest and easiest option for reordering
color components in pixel streams.
On Jan 7, 2009, at 4:27 PM, Eric Gorr wrote:
Well, I wrote the code to change the pixel format from BGRA to ARGB.
Running the code:
if ( (**pixMapHandle).pixelFormat == k32BGRAPixelFormat ) {
NSInteger x;
NSInteger y;
Ptr currentRow = (**pixMapHandle).baseAddr;
for ( y = 0; y < pixels_high; y++ ) {
Uint32 *currentPixel = (Uint32*)currentRow;
for ( x = 0; x < pixels_wide; x++ ) {
Uint8 *components = (Uint8*)currentPixel;
Uint8 temp;
temp = components[3];
components[3] = components[0];
components[0] = temp;
temp = components[1];
components[1] = components[2];
components[2] = temp;
currentPixel++;
}
currentRow += rowBytes;
}
}
over the pixel data to swap the components around allowed everything
to draw correctly.
I have a feeling there is a better way to do this and, if so, I am
interested.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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