• 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: Convert GWorldPtr into a NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Convert GWorldPtr into a NSImage
      • From: Eric Gorr <email@hidden>
References: 
 >Convert GWorldPtr into a NSImage (From: Eric Gorr <email@hidden>)
 >Re: Convert GWorldPtr into a NSImage (From: Graham Cox <email@hidden>)
 >Re: Convert GWorldPtr into a NSImage (From: Eric Gorr <email@hidden>)
 >Re: Convert GWorldPtr into a NSImage (From: Graham Cox <email@hidden>)
 >Re: Convert GWorldPtr into a NSImage (From: Daniel Kennett <email@hidden>)
 >Re: Convert GWorldPtr into a NSImage (From: Eric Gorr <email@hidden>)

  • Prev by Date: Recording video from a QCView to .mov
  • Next by Date: [iPhone] Update table cell text on selection in other view
  • Previous by thread: Re: Convert GWorldPtr into a NSImage
  • Next by thread: Re: Convert GWorldPtr into a NSImage
  • Index(es):
    • Date
    • Thread