zoukankan      html  css  js  c++  java
  • 如何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;
  • 相关阅读:
    python:HTML转义
    Python 安装 MySQLdb
    C# 获取当前路径方法
    配置 vim Python IDE 开发环境
    python:HTML转义
    Python list去重
    源码探秘
    加号的作用
    多态练习
    在web service用Cache要导入System.Web.HttpRuntime
  • 原文地址:https://www.cnblogs.com/OIMM/p/11430438.html
Copyright © 2011-2022 走看看