3
我一直在尝试将两个UIImage混合约2天,并且我一直在收到一些BAD_ACCESS错误。首先,我有两个具有相同方向的图像,基本上我使用CoreGraphics来进行混合。CGContextDrawImage返回错误访问
一个好奇的细节,每次我修改代码,第一次在设备上编译和运行代码时,我可以做任何我想做的事情而不会遇到任何麻烦。一旦我重新启动应用程序,就会出现错误并关闭程序。
任何人都可以给我一个灯?我试图动态访问baseImage大小,但它也给我访问不好。
这是我如何做混合的片段。
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();
补充:有时它会完美地工作,没问题。有时它只是叠加而不混合。其他它会使iphone崩溃。