当用户进行某些更改(裁剪,消除红眼,...),在内置 Photos.app iOS上,这些更改将不会应用到由相应

fullResolutionImage

返回的

ALAssetRepresentation

照片.

但是,这些更改应用到

thumbnail

并由

fullScreenImage

返回的

ALAssetRepresentation

.
此外,有关应用的更改信息可以在

ALAssetRepresentation

的元数据字典通过key

@"AdjustmentXMP"

发现.

我想这些更改应用到

fullResolutionImage

自己保持一致性.我发现在 iOS6的+

CIFilter

filterArrayFromSerializedXMP: inputImageExtent:error:

可以在此XMP元数据转换的

CIFilter

数组的:

ALAssetRepresentation *rep;
NSString *xmpString = rep.metadata[@"AdjustmentXMP"];
NSData *xmpData = [xmpString dataUsingEncoding:NSUTF8StringEncoding];

CIImage *image = [CIImage imageWithCGImage:rep.fullResolutionImage];

NSError *error = nil;
NSArray *filterArray = [CIFilter filterArrayFromSerializedXMP:xmpData
inputImageExtent:image.extent
error:&error];
if (error) {
NSLog(@"Error during CIFilter creation: %@", [error localizedDescription]);
}

CIContext *context = [CIContext contextWithOptions:nil];

for (CIFilter *filter in filterArray) {
[filter setValue:image forKey:kCIInputImageKey];
image = [filter outputImage];
}

然而,这仅适用于某些过滤器(裁剪,自动提升),但不是为别人像去除红眼.在这些情况下,

CIFilter

s有没有可见的效果.因此,我的问题:

  • 有没有人知道的方式来创建红眼消除

    CIFilter

    ? (在与Photos.app一致的方式,与关键

    kCIImageAutoAdjustRedEye

    该过滤器是不够的.例如,它没有考虑对眼睛的位置参数.)

  • 有没有一种可能的iOS 5下产生并应用这些过滤器?
 
 
 
解答
 
Rank --  0

ALAssetRepresentation* representation = [[self assetAtIndex:index] defaultRepresentation];
// create a buffer to hold the data for the asset's image
uint8_t *buffer = (Byte*)malloc(representation.size);// copy the data from the asset into the buffer
NSUInteger length = [representation getBytes:buffer fromOffset: 0.0 length:representation.size error:nil];

if (length==0) return nil;

// convert the buffer into a NSData object, free the buffer after

NSData *adata = [[NSData alloc] initWithBytesNoCopy:buffer length:representation.size freeWhenDone:YES];

// setup a dictionary with a UTI hint. The UTI hint identifies the
type of image we are dealing with (ie. a jpeg, png, or a possible RAW
file)

// specify the source hint

NSDictionary* sourceOptionsDict = [NSDictionary dictionaryWithObjectsAndKeys:

(id)[representation UTI] ,kCGImageSourceTypeIdentifierHint,

nil];

// create a CGImageSource with the NSData. A image source can contain x number of thumbnails and full images.

CGImageSourceRef sourceRef = CGImageSourceCreateWithData((CFDataRef) adata, (CFDictionaryRef) sourceOptionsDict);

[adata release];

CFDictionaryRef imagePropertiesDictionary;

// get a copy of the image properties from the CGImageSourceRef

imagePropertiesDictionary = CGImageSourceCopyPropertiesAtIndex(sourceRef,0, NULL);

CFNumberRef imageWidth = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelWidth);

CFNumberRef imageHeight = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelHeight);

int w = 0;

int h = 0;

CFNumberGetValue(imageWidth, kCFNumberIntType, &w);

CFNumberGetValue(imageHeight, kCFNumberIntType, &h);

// cleanup memory

CFRelease(imagePropertiesDictionary);

 
 
 
 

解读XMP元数据中ALAssetRepresentation的更多相关文章

  1. 此编译单元不包含在frame元数据中指定的factoryClass,无法加载配置的运行时共享库

    警告:此编译单元不包含在frame元数据中指定的factoryClass,无法加载配置的运行时共享库.要在没有运行时共享库的情况下进行编译,请将 -static-link-runtime-shared ...

  2. 解读 C 语言中的指针

    我想对很多学习C语言的新手来说,指针无疑是一个难点.但是,我觉得指针也是C语言特别重要的一个特性.也许,你在除了C和C++以外的编程语言中,很少看到指针.而C++中,也多用引用,而非指针.指针,作为一 ...

  3. 11.Spark Streaming源码解读之Driver中的ReceiverTracker架构设计以及具体实现彻底研究

    上篇文章详细解析了Receiver不断接收数据的过程,在Receiver接收数据的过程中会将数据的元信息发送给ReceiverTracker:   本文将详细解析ReceiverTracker的的架构 ...

  4. Spark Streaming源码解读之Driver中ReceiverTracker架构设计以具体实现彻底研究

    本期内容 : ReceiverTracker的架构设计 消息循环系统 ReceiverTracker具体实现 一. ReceiverTracker的架构设计 1. ReceiverTracker可以以 ...

  5. Android 从清单配置文件元数据中获取值

    最近在上班工作当中,也尝到了一些新的知识,现总结如下(1)从AndroidManifest.xml配置文件中获取meta数据 // 从Manifest.xml配置文件中获取数据 public stat ...

  6. 解读Python编程中的命名空间与作用域

    变量是拥有匹配对象的名字(标识符).命名空间是一个包含了变量名称们(键)和它们各自相应的对象们(值)的字典.一个Python表达式可以访问局部命名空间和全局命名空间里的变量.如果一个局部变量和一个全局 ...

  7. vue --- 解读vue的中webpack.base.config.js

    const path = require('path') const utils = require('./utils')// 引入utils工具模块,具体查看我的博客关于utils的解释,utils ...

  8. 辛星解读之php中的重点函数第一节之数组函数

    这里我已经写好它的pdf版本号了,比本博客更加适合阅读.首先说一下它在百度网盘的下载地址把:百度网盘下载 ,假设左边连接跪了.能够在浏览器中输入:http://pan.baidu.com/s/1qW5 ...

  9. 解读前端js中签名算法伪造H5游戏加分

    信息安全在我们日常开发中息息相关,稍有忽视则容易产生安全事故.对安全测试也提出更高要求.以下是笔者亲自实践过程: 一. 打开某个数钱游戏HTML5页面,在浏览器 F12 开发工具中,查看的js,如下, ...

随机推荐

  1. 转 intent常用功能

    1.从google搜索内容Intent intent = new Intent();intent.setAction(Intent.ACTION_WEB_SEARCH);intent.putExtra ...

  2. freemarker中判断对象是否为空

    <#if xxx?exists> 或则 <#if xxx??>两个问号??最简单方便

  3. 函数fsp_try_extend_data_file

    扩展表空间 /***********************************************************************//** Tries to extend t ...

  4. 实现窗口逐渐增大(moveTo(),resizeTo(),resizeBy()方法)

    moveTo()方法格式:window.moveTo(x,y); 功能:将窗口移动到指定坐标(x,y)处; resizeTo()方法格式:window.resizeTo(x,y); 功能:将当前窗口改 ...

  5. Jquery 模板插件 jquery.tmpl.js 的使用方法(1):基本语法,绑定,each循环,ajax获取json数据

    jquery.tmpl.js 是一个模板js  ,主要有2个方法 (1):$.template()方法,将一段script或者是Html编译为模板,例如 $.template('myTemplate' ...

  6. [反汇编练习] 160个CrackMe之015

    [反汇编练习] 160个CrackMe之015. 本系列文章的目的是从一个没有任何经验的新手的角度(其实就是我自己),一步步尝试将160个CrackMe全部破解,如果可以,通过任何方式写出一个类似于注 ...

  7. Windows Live Writer测试插件

    这是用WLW写的,测试 这是图片: 这是地图: 这是代码: 一会重发

  8. UVA 1663 Purifying Machine (二分图匹配,最大流)

    题意: 给m个长度为n的模板串,模板串由0和1和*三种组成,且每串至多1个*,代表可0可1.模板串至多匹配2个串,即*号改成0和1,如果没有*号则只能匹配自己.问:模板串可以缩减为几个,同样可以匹配原 ...

  9. LeetCode:Sort List

    Title: Sort a linked list in O(n log n) time using constant space complexity. 思路:考虑快速排序和归并排序,但是我的快速排 ...

  10. 【ASP.NET MVC】"[A]System.Web.WebPages.Razor.Configuration.HostSection 无法强制转换为 ..."的解决办法

    1.错误页面: “/”应用程序中的服务器错误. [A]System.Web.WebPages.Razor.Configuration.HostSection 无法强制转换为 [B]System.Web ...