CGContextDrawImage returning bad access

Posted by Marcelo on Stack Overflow See other posts from Stack Overflow or by Marcelo
Published on 2010-03-24T19:10:04Z Indexed on 2010/03/24 19:13 UTC
Read the original article Hit count: 285

Hello guys,

I've been trying to blend two UIImage for about 2 days now and I've been getting some BAD_ACCESS errors. First of all, I have two images that have the same orientation, basically I'm using the CoreGraphics to do the blending.

One curious detail, everytime I modify the code, the first time I compile and run it on device, I get to do everything I want without any sort of trouble. Once I restart the application, I get error and the program shuts down.

Can anyone give me a light? I tried accessing the baseImage sizes dynamically, but it gives me bad access too.

Here's a snippet of how I'm doing the blending.

 UIGraphicsBeginImageContext(CGSizeMake(320, 480));
 CGContextRef context = UIGraphicsGetCurrentContext();

 CGContextTranslateCTM(context, 0, 480);
 CGContextScaleCTM(context, 1.0, -1.0);

 CGContextDrawImage(context, rect, [baseImage CGImage]);
 CGContextSetBlendMode(context, kCGBlendModeOverlay);
 CGContextDrawImage(context, rect, [tmpImage CGImage]);

 [transformationView setImage:UIGraphicsGetImageFromCurrentImageContext()];
 UIGraphicsEndImageContext();

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about blending