0

使用СП时遇到问题

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

应用程序崩溃。请帮我!!

4

0 回答 0