使用СП
时遇到问题for (int16_t j = 0; j <= 1/kAlphaStep; j++) {
UIImage *blendingImage = [UIImage imageByBlendingImage:firstImage andImage:secondImage alpha:kAlphaStep*j];
buffer = [self pixelBufferFromImage:blendingImage andSize:size];
...}
并且
- (CVPixelBufferRef)pixelBufferFromImage:(UIImage *)img andSize:(CGSize)size {
CGImageRef image = img.CGImage;
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], kCVPixelBufferCGImageCompatibilityKey,
[NSNumber numberWithBool:YES], kCVPixelBufferCGBitmapContextCompatibilityKey,
nil];
CVPixelBufferRef pxbuffer = NULL;
CVReturn status = CVPixelBufferCreate(kCFAllocatorDefault, size.width,
size.height, kCVPixelFormatType_32ARGB, (__bridge CFDictionaryRef) options,
&pxbuffer);
NSParameterAssert(status == kCVReturnSuccess && pxbuffer != NULL);
...
return pxbuffer;
}
当我在循环中时,内存中的所有CGImageRef
。
如果我使用
if (image) {
CGImageRelease(image);
}
app崩溃了。 请帮帮我!!