更新时间:2023-11-09 23:04:28
CGBitmapContext
仅支持某些可能的像素格式。您可能想要 kCGImageAlphaPremultipliedLast
。
CGBitmapContext
supports only certain possible pixel formats. You probably want kCGImageAlphaPremultipliedLast
.
(这里是解释预乘alpha的解释。)
也请注意:
不需要malloc cacheBitmap
。由于您要传入 NULL
作为 CGBitmapContextCreate
的第一个参数,因此位图上下文将自行分配。
There is no need to malloc cacheBitmap
. Since you are passing in NULL
as the first argument to CGBitmapContextCreate
, the bitmap context will do its own allocation.
根据您的代码, self.bounds
可能不是要填充的正确矩形。使用 CGRectMake(0.f,0.f,size.width,size.height)
会更安全。
Depending on your code, self.bounds
may not be the correct rectangle to fill. It would be safer to use CGRectMake(0.f, 0.f, size.width, size.height)
.