CGContextDrawImage returns bad access

I have been trying to combine two UIImage for about 2 days and I am getting some BAD_ACCESS errors. First of all, I have two images with the same orientation, mostly I use CoreGraphics for blending.

One curious detail, every time I change the code, the first time I compile and run it on the device, I get everything I want without any problems. When I restart the application, I get an error message and the program shuts down.

Can anyone give me a light? I tried to access the baseImage parameters dynamically, but it also gives me poor access.

Here is a snippet of how I make the mix.

 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();

Addition: Sometimes it works fine, no problem. Sometimes it just overlays and does not mix. Others he resets the iphone.

+3
1

, CGImage . ,

    CGImageCreateCopy(sourceImage.CGImage);

, . - , .

+4

Source: https://habr.com/ru/post/1738385/


All Articles