ALAsset fullScreenImage fullResolutionImage 选中

问题描述

  • 1 ALAsset读图 fullScreenImage 情况正常
  • 2 fullResolutionImage 图片反转 需要重新设置图片选转值
// fullScreenImage可以直接初始化为UIImage
UIImage *tempImg = [UIImage imageWithCGImage:asset.defaultRepresentation.fullScreenImage];

// 需传入方向和缩放比例,否则方向和尺寸都不对
UIImage *tempImg = [UIImage imageWithCGImage:asset.defaultRepresentation.fullResolutionImage scale:asset.defaultRepresentation.scale orientation:(UIImageOrientation)asset.defaultRepresentation.orientation];

//实际使用 注意内存释放
ALAsset *asset = assets[i];
ALAssetRepresentation *assetRep = [asset defaultRepresentation];
UIImage *image = [UIImage imageWithCGImage:[assetRep fullResolutionImage] scale:assetRep.scale orientation:(UIImageOrientation)assetRep.orientation];

遍历视频文件

其中templist 存ALAsset指针对象

        NSMutableArray *tempList = [[NSMutableArray alloc] init];
        ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
        //文件夹
        [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
            [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
            //文件类型
                NSString *str = [result valueForProperty:ALAssetPropertyType];
                if ([str isEqualToString:ALAssetTypeVideo]){
                    [tempList addObject:result];
                }
            }];

        } failureBlock:^(NSError *error) {
            
        }];