CGBitmapContextCreate:不支持的参数组合

tar*_*mes 7 macos core-graphics

我在创建位图上下文时遇到此错误:

CGBitmapContextCreate:不支持的参数组合:8个整数位/组件; 24位/像素; 3组分色彩空间; kCGImageAlphaNone; 7936字节/行.

这是代码(请注意,上下文基于现有CGImage的参数:

context = CGBitmapContextCreate(NULL,
                                (int)pi.bufferSizeRequired.width,
                                (int)pi.bufferSizeRequired.height,
                                CGImageGetBitsPerComponent(imageRef),
                                0,
                                CGImageGetColorSpace(imageRef),
                                CGImageGetBitmapInfo(imageRef));
Run Code Online (Sandbox Code Playgroud)

宽度为2626,高度为3981.我将bytesPerRow保留为零,以便自动为我计算,并且它自己选择7936.

那么,地球上的不一致是什么?这让我疯了.

tar*_*mes 20

由于我不明白的原因,我通过将BitmapInfo参数设置为来解决了这个问题kCGImageAlphaNoneSkipLast.


小智 6

CGBitmapContextCreate:不支持的参数组合:8个整数位/组件; 24位/像素; 3组分色彩空间; kCGImageAlphaNone; 7936字节/行.

在Quartz 2D Programming文档中列出了支持的像素格式.不支持8/3/24组合,但8/3/32是独立于使用alpha或不使用alpha.