解读XMP元数据中ALAssetRepresentation
当用户进行某些更改(裁剪,消除红眼,...),在内置 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下产生并应用这些过滤器?
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的更多相关文章
- 此编译单元不包含在frame元数据中指定的factoryClass,无法加载配置的运行时共享库
警告:此编译单元不包含在frame元数据中指定的factoryClass,无法加载配置的运行时共享库.要在没有运行时共享库的情况下进行编译,请将 -static-link-runtime-shared ...
- 解读 C 语言中的指针
我想对很多学习C语言的新手来说,指针无疑是一个难点.但是,我觉得指针也是C语言特别重要的一个特性.也许,你在除了C和C++以外的编程语言中,很少看到指针.而C++中,也多用引用,而非指针.指针,作为一 ...
- 11.Spark Streaming源码解读之Driver中的ReceiverTracker架构设计以及具体实现彻底研究
上篇文章详细解析了Receiver不断接收数据的过程,在Receiver接收数据的过程中会将数据的元信息发送给ReceiverTracker: 本文将详细解析ReceiverTracker的的架构 ...
- Spark Streaming源码解读之Driver中ReceiverTracker架构设计以具体实现彻底研究
本期内容 : ReceiverTracker的架构设计 消息循环系统 ReceiverTracker具体实现 一. ReceiverTracker的架构设计 1. ReceiverTracker可以以 ...
- Android 从清单配置文件元数据中获取值
最近在上班工作当中,也尝到了一些新的知识,现总结如下(1)从AndroidManifest.xml配置文件中获取meta数据 // 从Manifest.xml配置文件中获取数据 public stat ...
- 解读Python编程中的命名空间与作用域
变量是拥有匹配对象的名字(标识符).命名空间是一个包含了变量名称们(键)和它们各自相应的对象们(值)的字典.一个Python表达式可以访问局部命名空间和全局命名空间里的变量.如果一个局部变量和一个全局 ...
- vue --- 解读vue的中webpack.base.config.js
const path = require('path') const utils = require('./utils')// 引入utils工具模块,具体查看我的博客关于utils的解释,utils ...
- 辛星解读之php中的重点函数第一节之数组函数
这里我已经写好它的pdf版本号了,比本博客更加适合阅读.首先说一下它在百度网盘的下载地址把:百度网盘下载 ,假设左边连接跪了.能够在浏览器中输入:http://pan.baidu.com/s/1qW5 ...
- 解读前端js中签名算法伪造H5游戏加分
信息安全在我们日常开发中息息相关,稍有忽视则容易产生安全事故.对安全测试也提出更高要求.以下是笔者亲自实践过程: 一. 打开某个数钱游戏HTML5页面,在浏览器 F12 开发工具中,查看的js,如下, ...
随机推荐
- poj 1151 Atlantis (离散化 + 扫描线 + 线段树 矩形面积并)
题目链接题意:给定n个矩形,求面积并,分别给矩形左上角的坐标和右上角的坐标. 分析: 映射到y轴,并且记录下每个的y坐标,并对y坐标进行离散. 然后按照x从左向右扫描. #include <io ...
- Android布局详解之一:FrameLayout
原创文章,如有转载,请注明出处:http://blog.csdn.net/yihui823/article/details/6702273 FrameLayout是最简单的布局了.所有放在布局里的 ...
- attachEvent,addEventListener事件绑定
兼容各主流浏览器的事件绑定(在同一个事件上添加多个处理函数). 1.绑定方法: //IE attachEvent(事件名, 函数) oBtn.attachEvent('onclick', aaa); ...
- BZOJ2482: [Spoj1557] Can you answer these queries II
题解: 从没见过这么XXX的线段树啊... T_T 我们考虑离线做,按1-n一个一个插入,并且维护区间[ j,i](i为当前插入的数)j<i的最优值. 但这个最优值!!! 我们要保存历史的最优值 ...
- asp.net批量发布博客到各大博客平台
新浪博客 http://upload.move.blog.sina.com.cn/blog_rebuild/blog/xmlrpc.php 网易博客 http://os.blog.163.com/ap ...
- Java知识点:javac命令
javac命令初窥 注:以下红色标记的参数在下文中有所讲解. 用法: javac <options> <source files> 其中, 可能的选项包括: -g ...
- 【Java学习笔记】Hello world
package aaa; public class aaa { public static void main(String args[]){ System.out.println("hel ...
- dbms_stats.gather_table_stats与analyze table 的区别[转贴]
Analyze StatementThe ANALYZE statement can be used to gather statistics for a specific table, index ...
- squid+nginx+apache
一.前言 二.编译安装 三.安装MySQL.memcache 四.安装Apache.PHP.eAccelerator.php-memcache 五.安装Squid 六.后记 一.前言,准备工作当前,L ...
- cmd远程连接数据库
在本地配置tnsname 打开C:\oracle\ora92\network\ADMIN\tnsnames.ora 加入如下参数. ora = (DESCRIPTION = (ADDRESS_LIST ...