Error occuring when loading photolibrary images : ERROR: FigCreateCGImageFromJPEG returned -12910. 423114 bytes. We will fall back to software decode

╄→гoц情女王★ 提交于 2020-01-04 05:53:11

问题


I'm working with an application in which I'm loading images from photolibrary.

I'm using the following code for binding the image to imageView.

-(void)loadImage:(UIImageView *)imgView FileName:(NSString *)fileName
{
   typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset);
   typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error);    

   ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
   {
     ALAssetRepresentation *rep = [myasset defaultRepresentation];
     CGImageRef iref = [rep fullResolutionImage];
     UIImage *lImage;
     if (iref)
     {
        lImage = [UIImage imageWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]];   
     }
     else
     {
        lImage = [UIImage imageNamed:@"Nofile.png"];
     }
     dispatch_async(dispatch_get_main_queue(), ^{
         [imgView setImage:lImage];
     });
   };

   ALAssetsLibraryAccessFailureBlock failureblock  = ^(NSError *myerror)
   {
       UIImage *images = [UIImage imageNamed:@"Nofile.png"];
        dispatch_async(dispatch_get_main_queue(), ^{
             [imgView setImage:images];
     });        
   };                   


    NSURL *asseturl = [NSURL URLWithString:fileName];

    ALAssetsLibrary *asset = [[ALAssetsLibrary alloc] init];
    [asset assetForURL:asseturl
           resultBlock:resultblock
          failureBlock:failureblock];
}

But when I tried to run it, an error is coming and the application is crashing sometimes. The error printed on console is:

** * ERROR: FigCreateCGImageFromJPEG returned -12910. 423114 bytes. We will fall back to software decode. Received memory warning. My photo library contains high resolution images and their size between 10-30 MB.


回答1:


Finally I fixed the issue. I think the issue is with fetching the full resolution image.

Instead of :

CGImageRef iref = [rep fullResolutionImage];

I used:

CGImageRef iref = [myasset aspectRatioThumbnail];

And everything worked fine. No error in console, no crash, but quality/resolution of the image is reduced.




回答2:


I have a similar error:

* ERROR: FigCreateCGImageFromJPEG returned -12909. 0 bytes. We will fall back to software decode.

app crush on call:

CGImageRef originalImage = [representation fullResolutionImage];

I fix it by replace to:

CGImageRef originalImage = [representation fullScreenImage]; 



回答3:


[UIImage imageWithCGImage:] 

imageWithCGImage is a stack memory function, it seems to overflow if the large image. What about using the heap functions?.

lImage = [[[UIImage alloc]initWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]] autorelease];


来源:https://stackoverflow.com/questions/14016879/error-occuring-when-loading-photolibrary-images-error-figcreatecgimagefromjpe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!