如何gif圖片轉data?完整解決


 

 

 

處理方法:

NSURL *imageRefURL = [info valueForKey:UIImagePickerControllerReferenceURL];

ALAssetsLibrary* assetLibrary = [[ALAssetsLibrary alloc] init];
void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *) = ^(ALAsset *asset) {

if (asset != nil) {

ALAssetRepresentation *rep = [asset defaultRepresentation];
Byte imageBuffer = (Byte)malloc(rep.size);
NSUInteger bufferSize = [rep getBytes:imageBuffer fromOffset:0.0 length:rep.size error:nil];
NSData *imageData = [NSData dataWithBytesNoCopy:imageBuffer length:bufferSize freeWhenDone:YES];

// 這個imageData就是gif的了
} else {}
};

[assetLibrary assetForURL:imageRefURL
resultBlock:ALAssetsLibraryAssetForURLResultBlock
failureBlock:^(NSError *error){
}];

info來源如下:

 

 

 

 

info數據來源:打開相冊選擇完成的代理方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM