将UIImage插孔放在内存中

时间:2013-10-28 21:41:04

标签: iphone memory core-graphics cgimage

只需添加带有此代码的UIImage,即可使内存大约50MB。图像本身的大小为{2448,3264}像素:

ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
    ALAssetRepresentation *rep = [myasset defaultRepresentation];
    CGImageRef iref = [rep fullResolutionImage];
    if (iref)
    {
        UIImage *selectedBackground = [UIImage imageWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]];
        CGImageRelease(iref);
        [self setBackgroundWithImage:selectedBackground orColor:nil];

    }
};
ALAssetsLibraryAccessFailureBlock failureblock  = ^(NSError *myerror)
{
    NSLog(@"Can't get image - %@",[myerror localizedDescription]);
};

ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:photoURL resultBlock:resultblock failureBlock:failureblock];

为什么内存会大幅跳跃?

0 个答案:

没有答案