title: Determining color order from an image file
body: <p>My app has several methods partly based on <a href="https://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone">this article</a>.</p>
  
  <p>Images, where I need to find the color at a location could come from the camera, the library, the app bundle, or generated within the app. I've just run into an issue where the order of the channels is different (it happens that the ones that are different are the ones generated by the app and saved in jpeg format for cache purposes).</p>
  
  <p>So my question is, how, preferably using the link as a starting point, can I determine the color order of a CGImage? I'm sure this is documented somewhere, but where?</p>
  
  <p>Using a method I've called +imageDump:, inspired by <a href="https://stackoverflow.com/questions/6073259/getting-rgb-pixel-data-from-cgimage/6077782#6077782">this article</a> I extract the following information from one image:</p>
  
  <pre><code>CGImageGetHeight: 120
  CGImageGetWidth:  120
  CGImageGetColorSpace: &lt;CGColorSpace 0x1c562050&gt; (kCGColorSpaceDeviceRGB)
  CGImageGetBitsPerPixel:     32
  CGImageGetBitsPerComponent: 8
  CGImageGetBytesPerRow:      480
  CGImageGetBitmapInfo: 0x00002002
    kCGBitmapAlphaInfoMask     = YES
    kCGBitmapFloatComponents   = NO
    kCGBitmapByteOrderMask     = YES
    kCGBitmapByteOrderDefault  = NO
    kCGBitmapByteOrder16Little = NO
    kCGBitmapByteOrder32Little = YES
    kCGBitmapByteOrder16Big    = YES
    kCGBitmapByteOrder32Big    = NO
  </code></pre>
  
  <p>and from another image, with the channels in a different order:</p>
  
  <pre><code>CGImageGetHeight: 120
  CGImageGetWidth:  120
  CGImageGetColorSpace: &lt;CGColorSpace 0x1c562050&gt; (kCGColorSpaceDeviceRGB)
  CGImageGetBitsPerPixel:     32
  CGImageGetBitsPerComponent: 8
  CGImageGetBytesPerRow:      480
  CGImageGetBitmapInfo: 0x00000001
    kCGBitmapAlphaInfoMask     = YES
    kCGBitmapFloatComponents   = NO
    kCGBitmapByteOrderMask     = NO
    kCGBitmapByteOrderDefault  = NO
    kCGBitmapByteOrder16Little = NO
    kCGBitmapByteOrder32Little = NO
    kCGBitmapByteOrder16Big    = NO
    kCGBitmapByteOrder32Big    = NO
  </code></pre>
  
  <p>It seems like this information somehow specifies the channel order, but I don't know how to interpret these constants. Or am I looking at the wrong thing?</p>