目前,我正在使用以下法典,从位于SOS的一处ALAsset获得UIImage。
ALAssetRepresentation *rep = [self.asset defaultRepresentation];
CGImageRef ref = [rep fullResolutionImage];
ALAssetOrientation orientation = [[self.asset valueForProperty:@"ALAssetPropertyOrientation"] intValue];
UIImage *image = [UIImage imageWithCGImage:ref scale:1.0 orientation:(UIImageOrientation)orientation];
This works very well as long as the image is reasonably small (e.g. taken with the device s camera). However if the image is too large (6000px^2 and more), the app will run out of memory during this step:
CGImageRef ref = [rep fullResolutionImage];
我愿在坠毁之前发现这一状况,或(理想)确定返回图像的最大尺寸。
我知道,fullScreenImage
将回归一个较小的形象,然而,该图像需要从动物体积图像中找到更高的分辨率。
Furthermore, using the byte size of the asset is unreliable as highly compressed formats such as JPG may well be small in packed size but still consume too much memory if their size in pixels is high (low detail images, highly compressed images).
如果能就如何掌握图像的尺寸和事先发现这种情况作出投入,以便我能够取消装载和显示错误,或如何找到这种大型资产的较小版本,将受到高度赞赏。