简体   繁体   中英

How to use constants to decode a bitmap

Starting from here:

CGBitmapInfo sampleCGImageBitmapInfo =  CGImageGetBitmapInfo(sampleCGImage); 

How do I use the constants in the defined in the CGImage Reference to determine the byte order use in the image. I want to test against the constants kCGBitmapByteOrder32Little and kCGBitmapByteOrder32Big. I would like to know how to code that. A great answer would be something like:

...
NSLog(@"kCGBitmapByteOrder32Big = %___", ____);

You can test it against the constants that are defined with CGBitmapInfo, like so:

sampleCGImageBitmapInfo = sampleCGBitmapInfo & kCGBitmapByteOrderMask;
if (sampleCGBitmapInfo == kCGBitmapByteOrderDefault)
{
    NSLog (@"Default byte order.\n");
}
else if (sampleCGBitmapInfo == kCGBitmapByteOrder16Little)
{
    NSLog (@"16 bit little endian\n");
}
else //... etc. for the other CGBitmapByteOrder constants

See here in the "Constants" section for details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM