我正在尝试创建位图上下文以调整从相机胶卷导入的图像的大小。这是代码:
CGContextRef bitmap = CGBitmapContextCreate(NULL,
newRect.size.width,
newRect.size.height,
CGImageGetBitsPerComponent(imageRef),
0,
CGImageGetColorSpace(imageRef),
CGImageGetBitmapInfo(imageRef));
Run Code Online (Sandbox Code Playgroud)
我在 iPhone 7 上截取了两个屏幕截图,当我尝试从相机胶卷加载它们时,一个失败,另一个成功。
第一个是失败的:
<CGImage 0x1701de3c0>
<<CGColorSpace 0x174a325c0> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; Display P3)>
width = 750, height = 1334, bpc = 16, bpp = 64, row bytes = 6000
kCGImageAlphaLast | kCGImageByteOrder16Little
is mask? No, has mask? No, has matte? No, should interpolate? Yes
Run Code Online (Sandbox Code Playgroud)
这是错误:
<Error>: CGBitmapContextCreate: unsupported parameter combination:
16 integer bits/component;
64 bits/pixel;
RGB color space model; kCGImageAlphaLast;
3840 bytes/row.
Valid parameters for RGB color space model …Run Code Online (Sandbox Code Playgroud)