I have a problem with creating a CGBitmapContext.
CGContextRef bitmapContext = CGBitmapContextCreate(nil, imageSize.width, imageSize.height, 8, imageSize.width * 4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst)
When I run my application normally it works. But when I run it in my 'Test application' (a running app that will perform my tests) the context is logged as (null) and I get the following errors:
<Error>: CGContextSetFillColorWithColor: invalid context 0x0
<Error>: CGContextFillRects: invalid context 0x0
<Error>: CGContextDrawImage: invalid context 0x0
<Error>: CGContextDrawImage: invalid context 0x0
<Error>: CGBitmapContextCreateImage: invalid context 0x0
My application doesn't crash. But apparently there is something wrong. (I know the errors are created by calling those methods with a nil context).
This error often appears when the size of the bitmap you're trying to create is CGSizeZero. Check the actual value of imageSize.
Besides, you leak the CGColorSpaceRef you pass into the function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With