I m 利用这一功能将一流的电压转换到电离层:
+(UIImage *)createUIImageFromIplImage:(IplImage *)image
{
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
NSData *data = [NSData dataWithBytes:image->imageData length:image->imageSize];
CGDataProviderRef provider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
CGImageRef imageRef = CGImageCreate(image->width, image->height,
image->depth, image->depth * image->nChannels, image->widthStep,
colorSpace, kCGImageAlphaPremultipliedLast|kCGBitmapByteOrderDefault,
provider, NULL, false, kCGRenderingIntentDefault);
UIImage* ret = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
CGDataProviderRelease(provider);
CGColorSpaceRelease(colorSpace);
return ret;
}
然而,在几张图像之后,我收到了记忆警报,随后发生了一起坠毁事件。 仪器显示,在分配记忆时,有问题的界线是:
NSData *data = [NSData dataWithBytes:image->imageData length:image->imageSize];
Somehow this memory is never released. How can this be fixed?