I am having problem with iOS 3.2, the same code works fine on iOS 4.2, but with the 3.2,
CGBitmapContextGetData return nil
my code:
CGContextRef context = CGBitmapContextCreate(
NULL,
image.size.width,
image.size.height,
8,
image.size.width * 4,
CGImageGetColorSpace(image.CGImage),
kCGImageAlphaPremultipliedLast
);
if (context != NULL)) {
CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, image.size.width, image.size.height), image.CGImage);
UInt32 *contextData = CGBitmapContextGetData( context );
}
contextData is nil when running on iOS 3.2, and returns the right value when running on iOS 4.2
Any one can explain why the result is different, and how to solve it?
Thanks.
Before iOS4 you had to explicity allocate memory yourself, from the documentation
So you should do something like
use that i.s.o. of NULL as your first parameter, and
free()it at an appropriate time.