简体   繁体   English

如何使用常量解码位图

[英]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. 如何使用CGImage参考中定义的常量来确定图像中使用的字节顺序。 I want to test against the constants kCGBitmapByteOrder32Little and kCGBitmapByteOrder32Big. 我想针对常数kCGBitmapByteOrder32Little和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: 您可以针对使用CGBitmapInfo定义的常量进行测试,如下所示:

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. 有关详细信息,请参见“常量”部分中的此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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