我们试图从ALAsset实例获取CG ImageRef并检查宽度/高度比.
ALAsset *alasset = ...CFImageRef = alasset.thumbnail; // return square thumbnail and not suitable for meCFImageRef = alasset.aspectRationthumbnail; //return aspect ration thumbnail,but very slowly
它不适合我们,因为它适用于许多文件.
此外,我们尝试从defaultRepresentation获取元数据并检查图像EXIF,但它工作缓慢.
NSDictionary *dictionary = [alasset defaultRepresentation] Metadata]; //very slowly to
有没有办法让它变得更好?
谢谢
解决方法 最后,我发现了ALAsset的这个解决方案:ALAssetsLibrary *AssetsLibrary = ...;NSOperation *queue = [NSoperationQueue alloc] init];static Nsstring * const kAssetQueue@R_404_6889@ = ...;static NSUInteger const kAssetConcurrentoperationCount = ...; //I use 5 queue.maxConcurrentoperationCount = kAssetConcurrentoperationCount;queue.@R_404_6889@ = kAssetQueue@R_404_6889@;dispatch_async(dispatch_get_main_queue(),^{ [AssetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group,BOol *stop) { /*You must check the group is not nil */ if (!group) return; /*Then you need to select group where you will search panoramas: for iPhone-Simulator it's @"Saved Photos" and "Camera Roll" for iPhone. It's actuality only for iOS 7 or early. */ static Nsstring * const kAssetGroup@R_404_6889@ = ...; if ([[group valueForProperty:ALAssetsGroupProperty@R_404_6889@] kAssetGroup@R_404_6889@]) { [group enumerateAssetsUsingBlock:^(ALAsset *asset,NSUInteger index,BOol *stop) { if (!asset) return; [queue addOperationWithBlock:^{ //I use @autoreleasepool for instant memory release,after I find panoramas asset url @autoreleasepool { ALAssetRepresentation *defaultRepresentation = asset.defaultRepresentation; if ([defaultRepresentation.UTI isEqualToString:@"public.jpeg"]) { NSDictionary *Metadata = defaultRepresentation.Metadata; if (!Metadata) return; if (Metadata[@"PixelWIDth"] && Metadata[@"PixelHeight"]) { NSInteger pixelWIDth = [Metadata[@"PixelWIDth"] integerValue]; NSInteger pixelHeight = [Metadata[@"PixelHeight"] integerValue]; static NSUInteger const kSIDesRelationshipConstant = ...; //I use 2 static NSUInteger const kMinimalPanoramaHeight = ...; //I use 600 if (pixelHeight >= kMinimalPanoramaHeight && pixelWIDth/pixelHeight >= kSIDesRelationshipConstant) {/*So,that is panorama.*/} } }]; }]; } } failureBlock:^(NSError *error) { //Some failing action,you kNow. }];};
那是.所以,我认为这不是最好的解决方案.但是,今天我没有找到更好的.
总结以上是内存溢出为你收集整理的ios – 如何从ALAsset对象获取全景图全部内容,希望文章能够帮你解决ios – 如何从ALAsset对象获取全景图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)