CGContextRef context = CGBitmapContextCreate(nil,
width, //if width More than 6002/4
height,
8,
width*4,//if width*4 > 6002
colorSpace,
kCGImageAlphaPremultipliedFirst |kCGBitmapByteOrder32Little );我想建立一个大的位图(宽度<= 2500)时,width*4>6002有一个错误
<Error>: CGBitmapContextCreate: unsupported parameter combination:
8 integer bits/component; 32 bits/pixel;
3-component color space; kCGImageAlphaPremultipliedFirst; 6002 bytes/row.如何构建一个大的位图,谢谢。
发布于 2012-07-31 21:31:37
问题是6002字节/行,因为这里每个像素需要4个字节,但是6002不能被4整除,而不是余数。最好计算每像素的行数:
size_t width = 1920;
size_t height = 1080;
CGContextRef context = CGBitmapContextCreate(
NULL,
width,
height,
8,
width * 4,
colorSpace,
kCGImageAlphaPremultipliedFirst |kCGBitmapByteOrder32Little );发布于 2012-07-31 19:51:22
新的bytesPerRow将与原始图像不同。您需要计算新的bytesPerRow。
bytesPerPixel * targetWidth
你不能用静态8和4。
有关颜色空间和相对bytesPerPixel,请参考this。
https://stackoverflow.com/questions/11739340
复制相似问题