ios – 从ALAssetRepresentation获取“修饰”图像

ios – 从ALAssetRepresentation获取“修饰”图像,第1张

概述给定ALAssetRepresentation,是否可以获得其全分辨率润饰图像? 如果我使用fullResolutionImage方法,我会获得全分辨率图像,但不会以任何方式进行调整. 如果我使用方法fullScreenImageI获取修饰后的图像,但缩小为适合显示全屏. 这不是那么容易,但你可以.请注意,这也将应用用户在Photos.app中完成的任何裁剪: ALAssetRepresentat @H_403_0@ @H_403_0@ 给定ALAssetRepresentation,是否可以获得其全分辨率润饰图像?

如果我使用fullResolutionImage方法,我会获得全分辨率图像,但不会以任何方式进行调整.

如果我使用方法fullScreenImageI获取修饰后的图像,但缩小为适合显示全屏.

解决方法 这不是那么容易,但你可以.请注意,这也将应用用户在Photos.app中完成的任何裁剪:

ALAssetRepresentation *representation = asset.defaultRepresentation;CGImageRef fullResolutionImage = CGImageRetain(representation.fullResolutionImage);// AdjustmentXMP constains the Extensible Metadata Platform XML of the photo// This XML describe the transformation done to the image.// http://en.wikipedia.org/wiki/Extensible_Metadata_Platform// Have in mind that the key is not exactly documented.Nsstring *adjustmentXMP = [representation.Metadata objectForKey:@"AdjustmentXMP"];NSData *adjustmentXMPData = [adjustmentXMP dataUsingEnCoding:NSUTF8StringEnCoding];NSError *__autoreleasing error = nil;CGRect extend = CGRectZero;extend.size = representation.dimensions;NSArray *filters = [CIFilter filterarrayFromSerializedXMP:adjustmentXMPData inputimageExtent:extend error:&error];if (filters){  CIImage *image = [CIImage imageWithCGImage:fullResolutionImage];  CIContext *context = [CIContext contextWithOptions:nil];  for (CIFilter *filter in filters)  {    [filter setValue:image forKey:kCIInputimageKey];    image = [filter outputimage];  }  CGImageRelease(fullResolutionImage);  fullResolutionImage = [context createCGImage:image fromrect:image.extent];}// At this moment fullResolutionImage will be the filtered image,or the full// resolution one if no filters were applIEd.// You will need to CGImageRelease fullResolutionImage after you have finished// working with it.
@H_403_0@ 总结

以上是内存溢出为你收集整理的ios – 从ALAssetRepresentation获取“修饰”图像全部内容,希望文章能够帮你解决ios – 从ALAssetRepresentation获取“修饰”图像所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1065179.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存