当前位置:   article > 正文

iOS中ImageIO框架详解与应用分析

cgimagedestinationcreatewithurl只支持.png吗

iOS中ImageIO框架详解与应用分析

一、引言

    ImageIO框架提供了读取与写入图片数据的基本方法,使用它可以直接获取到图片文件的内容数据,ImageIO框架中包含6个头文件,其中完成主要功能的是前两个头文件中定义的方法:

1.CGImageSource.h:负责读取图片数据。

2.CGImageDestination.h:负责写入图片数据。

3.CGImageMetadata.h:图片文件元数据类。

4.CGImageProperties:定义了框架中使用的字符串常量和宏。

5.ImageIOBase.h:预处理逻辑,无需关心。

二、CGImageSource详解

    CGImageSource类的主要作用是用来读取图片数据,在平时开发中,关于图片我们使用的最多的可能是UIImage类,UIImage是iOS系统UI系统中用于构建图像对象的类,但是其中只有图像数据,实际上一个图片文件中存储的除了图片数据外,还有一些地理位置、设备类型、时间等信息,除此之外,一个图片文件中可能存储的也不只一张图像(例如gif文件)。CGImageSource就是这样的一个抽象图片数据示例,从其中可以获取到我们所关心的所有数据。

    读取图片文件数据,并将其展示在视图的简单代码示例如下:

  1. //获取图片文件路径
  2. NSString * path = [[NSBundle mainBundle]pathForResource:@"timg" ofType:@"jpeg"];
  3. NSURL * url = [NSURL fileURLWithPath:path];
  4. CGImageRef myImage = NULL;
  5. CGImageSourceRef myImageSource;
  6. //通过文件路径创建CGImageSource对象
  7. myImageSource = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
  8. //获取第一张图片
  9. myImage = CGImageSourceCreateImageAtIndex(myImageSource,
  10. 0,
  11. NULL);
  12. CFRelease(myImageSource);
  13. UIImageView * image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
  14. image.image = [UIImage imageWithCGImage:myImage];
  15. [self.view addSubview:image];

上面的示例代码采用的是本地的一个素材文件,当然通过网络图片链接也是可以创建CGImageSource独享的。除了通过URL链接的方式创建对象,ImageIO框架中还提供了两种方法,解析如下:

  1. //通过数据提供器创建CGImageSource对象
  2. /*
  3. CGDataProviderRef是CoreGraphics框架中的一个数据读取类,其也可以通过Data数据,URL和文件名来创建
  4. */
  5. CGImageSourceRef __nullable CGImageSourceCreateWithDataProvider(CGDataProviderRef __nonnull provider, CFDictionaryRef __nullable options);
  6. //通过Data数据创建CGImageSource对象
  7. CGImageSourceRef __nullable CGImageSourceCreateWithData(CFDataRef __nonnull data, CFDictionaryRef __nullable options);

需要注意,上面所提到的所有创建CGImageSource的方法中都可以传入一个CFDictionaryRef类型的字典,可以配置的键值意义如下:

  1. /*
  2. 设置一个预期的图片文件格式,需要设置为字符串类型的值
  3. */
  4. const CFStringRef kCGImageSourceTypeIdentifierHint;
  5. /*
  6. 设置是否以解码的方式读取图片数据 默认为kCFBooleanTrue
  7. 如果设置为true,在读取数据时就进行解码 如果为false 则在渲染时才进行解码
  8. */
  9. const CFStringRef kCGImageSourceShouldCache;
  10. /*
  11. 返回CGImage对象时是否允许使用浮点值 默认为kCFBooleanFalse
  12. */
  13. const CFStringRef kCGImageSourceShouldAllowFloa;
  14. /*
  15. 设置如果不存在缩略图则创建一个缩略图,缩略图的尺寸受开发者设置影响,如果不设置尺寸极限,则为图片本身大小
  16. 默认为kCFBooleanFalse
  17. */
  18. const CFStringRef kCGImageSourceCreateThumbnailFromImageIfAbsent;
  19. /*
  20. 设置是否创建缩略图,无论原图像有没有包含缩略图kCFBooleanFalse
  21. */
  22. const CFStringRef kCGImageSourceCreateThumbnailFromImageAlways;
  23. /*
  24. 设置缩略图的宽高尺寸 需要设置为CFNumber值
  25. */
  26. const CFStringRef kCGImageSourceThumbnailMaxPixelSize;
  27. /*
  28. 设置缩略图是否进行Transfrom变换
  29. */
  30. const CFStringRef kCGImageSourceCreateThumbnailWithTransform;

CGImageSource类中其他方法解析如下:

  1. //获取CGImageSource类在CoreFundation框架中的id
  2. CFTypeID CGImageSourceGetTypeID (void);
  3. //获取所支持的图片格式数组
  4. CFArrayRef __nonnull CGImageSourceCopyTypeIdentifiers(void);
  5. //获取CGImageSource对象的图片格式
  6. CFStringRef __nullable CGImageSourceGetType(CGImageSourceRef __nonnull isrc);
  7. //获取CGImageSource中的图片张数 不包括缩略图
  8. size_t CGImageSourceGetCount(CGImageSourceRef __nonnull isrc);
  9. //获取CGImageSource的文件信息
  10. /*
  11. 字典参数可配置的键值对与创建CGImageSource所传参数意义一致
  12. 返回的字典中的键值意义后面介绍
  13. */
  14. CFDictionaryRef __nullable CGImageSourceCopyProperties(CGImageSourceRef __nonnull isrc, CFDictionaryRef __nullable options);
  15. //获取CGImageSource中某个图像的附加数据
  16. /*
  17. index参数设置获取第几张图像 options参数可配置的键值对与创建CGImageSource所传参数意义一致
  18. 返回的字典中的键值意义后面介绍
  19. */
  20. CFDictionaryRef __nullable CGImageSourceCopyPropertiesAtIndex(CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable options);
  21. //获取图片的元数据信息 CGImageMetadataRef类是图像原数据的抽象
  22. CGImageMetadataRef __nullable CGImageSourceCopyMetadataAtIndex (CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable options);
  23. //获取CGImageSource中的图片数据
  24. CGImageRef __nullable CGImageSourceCreateImageAtIndex(CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable options);
  25. //删除一个指定索引图像的缓存
  26. void CGImageSourceRemoveCacheAtIndex(CGImageSourceRef __nonnull isrc, size_t index);
  27. //获取某一帧图片的缩略图
  28. CGImageRef __nullable CGImageSourceCreateThumbnailAtIndex(CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable options);
  29. //创建一个空的CGImageSource容器,逐步加载大图片
  30. CGImageSourceRef __nonnull CGImageSourceCreateIncremental(CFDictionaryRef __nullable options);
  31. //使用新的数据更新CGImageSource容器
  32. void CGImageSourceUpdateData(CGImageSourceRef __nonnull isrc, CFDataRef __nonnull data, bool final);
  33. //更新数据提供器来填充CGImageSource容器
  34. void CGImageSourceUpdateDataProvider(CGImageSourceRef __nonnull isrc, CGDataProviderRef __nonnull provider, bool final);
  35. //获取当前CGImageSource的状态
  36. /*
  37. CGImageSourceStatus枚举意义:
  38. typedef CF_ENUM(int32_t, CGImageSourceStatus) {
  39. kCGImageStatusUnexpectedEOF = -5, //文件结尾出错
  40. kCGImageStatusInvalidData = -4, //数据无效
  41. kCGImageStatusUnknownType = -3, //未知的图片类型
  42. kCGImageStatusReadingHeader = -2, //读标题过程中
  43. kCGImageStatusIncomplete = -1, //操作不完整
  44. kCGImageStatusComplete = 0 //操作完整
  45. };
  46. */
  47. CGImageSourceStatus CGImageSourceGetStatus(CGImageSourceRef __nonnull isrc);
  48. //同上,获取某一个图片的状态
  49. CGImageSourceStatus CGImageSourceGetStatusAtIndex(CGImageSourceRef __nonnull isrc, size_t index);

三、CGImageDestination详解

    CGImageSource是图片文件数据的抽象对象,而CGImageDestination的作用则是将抽象的图片数据写入指定的目标中。将图片写成文件示例如下:

  1. //创建存储路径
  2. NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
  3. NSString *newPath = [paths.firstObject stringByAppendingPathComponent:[NSString stringWithFormat:@"image.png"]];
  4. CFURLRef URL = CFURLCreateWithFileSystemPath (
  5. kCFAllocatorDefault,
  6. (CFStringRef)newPath,
  7. kCFURLPOSIXPathStyle,
  8. false);
  9. //创建CGImageDestination对象
  10. CGImageDestinationRef myImageDest = CGImageDestinationCreateWithURL(URL,CFSTR("public.png"), 1, NULL);
  11. UIImage * image = [UIImage imageNamed:@"timg.jpeg"];
  12. //写入图片
  13. CGImageDestinationAddImage(myImageDest, image.CGImage, NULL);
  14. CGImageDestinationFinalize(myImageDest);
  15. CFRelease(myImageDest);

同样,除了可以直接将图片数据写入url外,也可以Data数据或数据消费器,方法如下:

  1. //将图片数据写入数据消费者
  2. CGImageDestinationRef __nullable CGImageDestinationCreateWithDataConsumer(CGDataConsumerRef __nonnull consumer, CFStringRef __nonnull type, size_t count, CFDictionaryRef __nullable options);
  3. //将图片数据写入Data
  4. CGImageDestinationRef __nullable CGImageDestinationCreateWithData(CFMutableDataRef __nonnull data, CFStringRef __nonnull type, size_t count, CFDictionaryRef __nullable options);

需要注意,上面方法的type参数设置写入数据的文件格式,必须为ImageIO框架所支持的格式,前面有方法可以获取所有支持的格式,还有一点,这3个写入方法的中options参数目前并没有什么作用,其是留给未来使用的,目前传入NULL即可。

CGImageDestination类中的其他方法解析如下:

  1. //获取CGImageDestination的CFTypeID
  2. CFTypeID CGImageDestinationGetTypeID(void);
  3. //获取CGImageDestination所支持的图片文件类型
  4. /*
  5. 目前支持如下:iOS10.1
  6. (
  7. "public.jpeg",
  8. "public.png",
  9. "com.compuserve.gif",
  10. "public.tiff",
  11. "public.jpeg-2000",
  12. "com.microsoft.ico",
  13. "com.microsoft.bmp",
  14. "com.adobe.photoshop-image",
  15. "com.adobe.pdf",
  16. "com.truevision.tga-image",
  17. "com.ilm.openexr-image",
  18. "public.pbm",
  19. "public.pvr",
  20. "org.khronos.astc",
  21. "org.khronos.ktx",
  22. "com.microsoft.dds",
  23. "com.apple.rjpeg"
  24. )
  25. */
  26. CFArrayRef __nonnull CGImageDestinationCopyTypeIdentifiers(void);
  27. //设置图片文件属性
  28. /*
  29. 可以设置的键值对意义如下:
  30. const CFStringRef kCGImageDestinationLossyCompressionQuality; //设置压缩质量 0-1之间的cfnumberref值
  31. const CFStringRef kCGImageDestinationBackgroundColor; //将图片数据写为无alpha通道时的默认背景色 cgcolor值
  32. */
  33. void CGImageDestinationSetProperties(CGImageDestinationRef __nonnull idst, CFDictionaryRef __nullable properties);
  34. //向CGImageDestination中添加一张图片 其中的option参数意义和上面一致,设置此图片的质量与无alpha默认背景色
  35. void CGImageDestinationAddImage(CGImageDestinationRef __nonnull idst, CGImageRef __nonnull image, CFDictionaryRef __nullable properties);
  36. //通过CGImageSource对象来向CGImageDestination中添加图片
  37. void CGImageDestinationAddImageFromSource(CGImageDestinationRef __nonnull idst, CGImageSourceRef __nonnull isrc, size_t index, CFDictionaryRef __nullable properties);
  38. //进行写入操作 执行此方法后 不可以在写入其他信息
  39. bool CGImageDestinationFinalize(CGImageDestinationRef __nonnull idst);
  40. //添加图片元信息
  41. void CGImageDestinationAddImageAndMetadata(CGImageDestinationRef __nonnull idst, CGImageRef __nonnull image, CGImageMetadataRef __nullable metadata, CFDictionaryRef __nullable options);
  42. //将CGImageSource信息拷贝进CGImageDestination
  43. /*
  44. options参数可以用来添加元信息
  45. */
  46. bool CGImageDestinationCopyImageSource(CGImageDestinationRef __nonnull idst, CGImageSourceRef __nonnull isrc, CFDictionaryRef __nullable options, __nullable CFErrorRef * __nullable err);

上面列举的方法中,CGImageDestinationCopyImageSource()方法中的options参数可以添加一些图片的元信息,可以设置的键值对意义如下:

  1. //设置元信息 需要设置为CGImageMetadataRef对象
  2. const CFStringRef kCGImageDestinationMetadata;
  3. //是否将CGImageSource的元信息信息合并操作 默认为kCFBooleanFalse
  4. const CFStringRef kCGImageDestinationMergeMetadata;
  5. //XMP数据是否不被写入 默认为kCFBooleanFalse
  6. const CFStringRef kCGImageMetadataShouldExcludeXMP;
  7. //GPS信息是否不被写入 默认为kCFBooleanFalse
  8. const CFStringRef kCGImageMetadataShouldExcludeGPS;
  9. //更新元数据的时间值 需要设置为CFStringRef或者CFDateRef
  10. const CFStringRef kCGImageDestinationDateTime;
  11. //更新元数据的方向值 需要设置为NSNumber1-8
  12. const CFStringRef kCGImageDestinationOrientation;

四、关于CGImageMetadata

    前面我们很多次提到元数据,CGImageMetadata类就是元数据的抽象,其中封装了一些方法供开发者读取或写入元数据信息。奇怪的是Apple的官方文档与API文档中并没有CGImageMetadata的介绍与解释,博客中本部分的内容,多出自我的理解,有疏漏和不对的地方,清楚的朋友可以指点与建议。

    前边介绍,CGImageSource中有获取图片元数据的方法,CGImageDestination中也有写入图片元数据的方法,元数据中抽象出的CGImageMetadataTag是对具体数据内容的封装。CGImageMetadata解析如下:

  1. //获取CGImageMetadata类的CFTypeID
  2. CFTypeID CGImageMetadataGetTypeID(void);
  3. //创建一个空的可变的CGImageMetadata对象
  4. CGMutableImageMetadataRef __nonnull CGImageMetadataCreateMutable(void);
  5. //拷贝一个可变的CGImageMetadata对象
  6. CGMutableImageMetadataRef __nullable CGImageMetadataCreateMutableCopy(CGImageMetadataRef __nonnull metadata);
  7. //获取CGImageMetadataTag类的CFTypeID
  8. CFTypeID CGImageMetadataTagGetTypeID(void);
  9. //创建一个CGImageMetadataTag对象
  10. /*
  11. 这个方法比较复杂
  12. xmlns参数设置命名空间
  13. prefix参数设置命名空间的缩写或前缀
  14. name参数设置CGImageMetadataTag的名称
  15. type参数设置CGImageMetadataTag对应值的类型
  16. value参数设置CGImageMetadataTag的对应值
  17. */
  18. CGImageMetadataTagRef __nullable CGImageMetadataTagCreate (CFStringRef __nonnull xmlns, CFStringRef __nullable prefix, CFStringRef __nonnull name, CGImageMetadataType type, CFTypeRef __nonnull value);

上面创建CGImageMetadataTag的方法中,xmlns设置命名空间,必须使用一个预定义的命名空间或者自定义的命名空间,对于自定义的命名空间,必须遵守Adobe的XMP规范。一些共用的命名空间定义如下:

  1. //Exif命名空间
  2. const CFStringRef kCGImageMetadataNamespaceExif;
  3. //ExifAux命名空间
  4. const CFStringRef kCGImageMetadataNamespaceExifAux;
  5. //ExifEX命名空间
  6. const CFStringRef kCGImageMetadataNamespaceExifEX;
  7. //DublineCore命名空间
  8. const CFStringRef kCGImageMetadataNamespaceDublinCore;
  9. //IPTCCore命名空间
  10. const CFStringRef kCGImageMetadataNamespaceIPTCCore;
  11. //Photoshop命名空间
  12. const CFStringRef kCGImageMetadataNamespacePhotoshop;
  13. //TIFF命名空间
  14. const CFStringRef kCGImageMetadataNamespaceTIFF;
  15. //XMPBasic命名空间
  16. const CFStringRef kCGImageMetadataNamespaceXMPBasic;
  17. //XMPRights命名空间
  18. const CFStringRef kCGImageMetadataNamespaceXMPRights;

上面创建CGImageMetadataTag的方法中prefix设置命名空间缩写或前缀,同样一些公用的前缀定义如下:

  1. //Exif命名空间前缀
  2. const CFStringRef kCGImageMetadataPrefixExif;
  3. //ExifAux命名空间前缀
  4. const CFStringRef kCGImageMetadataPrefixExifAux;
  5. //ExifEX命名空间前缀
  6. const CFStringRef kCGImageMetadataPrefixExifEX;
  7. //DublinCore命名空间前缀
  8. const CFStringRef kCGImageMetadataPrefixDublinCore;
  9. //IPCCore命名空间前缀
  10. const CFStringRef kCGImageMetadataPrefixIPTCCore;
  11. //Photoshop命名空间前缀
  12. const CFStringRef kCGImageMetadataPrefixPhotoshop;
  13. //TIFF命名空间前缀
  14. const CFStringRef kCGImageMetadataPrefixTIFF;
  15. //XMPBasic命名空间前缀
  16. const CFStringRef kCGImageMetadataPrefixXMPBasic;
  17. //XMPRights命名空间前缀
  18. const CFStringRef kCGImageMetadataPrefixXMPRights;

上面创建CGImageMetadataTag的方法中type设置对应值的类型,其是一个CGImageMetadataType类型的枚举,意义如下:

  1. typedef CF_ENUM(int32_t, CGImageMetadataType) {
  2. //无效的数据类型
  3. kCGImageMetadataTypeInvalid = -1,
  4. //基本的CFType类型
  5. kCGImageMetadataTypeDefault = 0,
  6. //字符串类型
  7. kCGImageMetadataTypeString = 1,
  8. //无需集合类型
  9. kCGImageMetadataTypeArrayUnordered = 2,
  10. //有序集合类型
  11. kCGImageMetadataTypeArrayOrdered = 3,
  12. //有序阵列
  13. kCGImageMetadataTypeAlternateArray = 4,
  14. //特殊的数组 其中元素进行不同的本地化
  15. kCGImageMetadataTypeAlternateText = 5,
  16. //结构类型 如字典
  17. kCGImageMetadataTypeStructure = 6
  18. };

获取到CGImageMetadataTag后,可以通过如下方法来获取其中封装的信息:

  1. //获取标签的命名空间
  2. CFStringRef __nullable CGImageMetadataTagCopyNamespace(CGImageMetadataTagRef __nonnull tag);
  3. //获取标签的命名空间前缀
  4. CFStringRef __nullable CGImageMetadataTagCopyPrefix(CGImageMetadataTagRef __nonnull tag);
  5. //获取标签名称
  6. CFStringRef __nullable CGImageMetadataTagCopyName(CGImageMetadataTagRef __nonnull tag);
  7. //获取标签的值
  8. CFTypeRef __nullable CGImageMetadataTagCopyValue(CGImageMetadataTagRef __nonnull tag);
  9. //获取标签值的类型
  10. CGImageMetadataType CGImageMetadataTagGetType(CGImageMetadataTagRef __nonnull tag);
  11. //获取标签的Qualifier数组
  12. CFArrayRef __nullable CGImageMetadataTagCopyQualifiers(CGImageMetadataTagRef __nonnull tag);

下面这些方法用于向CGImageMetadata中添加标签或者获取标签:

  1. //获取CGImageMetadata中的所有标签
  2. CFArrayRef __nullable CGImageMetadataCopyTags(CGImageMetadataRef __nonnull metadata);
  3. //通过路径查找特殊的标签
  4. CGImageMetadataTagRef __nullable CGImageMetadataCopyTagWithPath(CGImageMetadataRef __nonnull metadata, CGImageMetadataTagRef __nullable parent, CFStringRef __nonnull path);
  5. //通过路径查找特殊标签的值
  6. CFStringRef __nullable CGImageMetadataCopyStringValueWithPath(CGImageMetadataRef __nonnull metadata, CGImageMetadataTagRef __nullable parent, CFStringRef __nonnull path);
  7. //为一个前缀注册一个命名空间
  8. bool CGImageMetadataRegisterNamespaceForPrefix(CGMutableImageMetadataRef __nonnull metadata, CFStringRef __nonnull xmlns, CFStringRef __nonnull prefix, __nullable CFErrorRef * __nullable err);
  9. //通过路径为CGImageMetadata设置标签
  10. bool CGImageMetadataSetTagWithPath(CGMutableImageMetadataRef __nonnull metadata, CGImageMetadataTagRef __nullable parent, CFStringRef __nonnull path, CGImageMetadataTagRef __nonnull tag);
  11. //通过路径为CGImageMetadata设置标签的值
  12. bool CGImageMetadataSetValueWithPath(CGMutableImageMetadataRef __nonnull metadata, CGImageMetadataTagRef __nullable parent, CFStringRef __nonnull path, CFTypeRef __nonnull value);
  13. //通过路径移除一个标签
  14. bool CGImageMetadataRemoveTagWithPath(CGMutableImageMetadataRef __nonnull metadata, CGImageMetadataTagRef __nullable parent, CFStringRef __nonnull path);
  15. //对标签进行枚举
  16. void CGImageMetadataEnumerateTagsUsingBlock(CGImageMetadataRef __nonnull metadata, CFStringRef __nullable rootPath, CFDictionaryRef __nullable options, CGImageMetadataTagBlock __nonnull block);

五、CGImageProperties中定义的字典意义

    前面提到的CGImageSourceCopyProperties方法与CGImageSourceCopyPropertiesAtIndex方法都会返回一个字典,字典中可能包含如下有意义的键:

  1. //TIFF信息字典
  2. const CFStringRef kCGImagePropertyTIFFDictionary;
  3. /GIF信息字典
  4. const CFStringRef kCGImagePropertyGIFDictionary;
  5. //JFIF信息字典
  6. const CFStringRef kCGImagePropertyJFIFDictionary;
  7. //EXif信息字典
  8. const CFStringRef kCGImagePropertyExifDictionary;
  9. //PNG信息字典
  10. const CFStringRef kCGImagePropertyPNGDictionary;
  11. //IPTC信息字典
  12. const CFStringRef kCGImagePropertyIPTCDictionary;
  13. //GPS信息字典
  14. const CFStringRef kCGImagePropertyGPSDictionary;
  15. //原始信息字典
  16. const CFStringRef kCGImagePropertyRawDictionary;
  17. //CIFF信息字典
  18. const CFStringRef kCGImagePropertyCIFFDictionary;
  19. //佳能相机信息字典
  20. const CFStringRef kCGImagePropertyMakerCanonDictionary;
  21. //尼康相机信息字典
  22. const CFStringRef kCGImagePropertyMakerNikonDictionary;
  23. //柯尼卡相机信息字典
  24. const CFStringRef kCGImagePropertyMakerMinoltaDictionary;
  25. //富士相机信息字典
  26. const CFStringRef kCGImagePropertyMakerFujiDictionary;
  27. //奥林巴斯相机信息字典
  28. const CFStringRef kCGImagePropertyMakerOlympusDictionary;
  29. //宾得相机信息字典
  30. const CFStringRef kCGImagePropertyMakerPentaxDictionary;
  31. //对应Photoshop相片的信息字典
  32. const CFStringRef kCGImageProperty8BIMDictionary;
  33. //NDG信息字典
  34. const CFStringRef kCGImagePropertyDNGDictionary ;
  35. //ExifAux信息字典
  36. const CFStringRef kCGImagePropertyExifAuxDictionary;
  37. //OpenEXR信息字典
  38. const CFStringRef kCGImagePropertyOpenEXRDictionary;
  39. //Apple相机信息字典
  40. const CFStringRef kCGImagePropertyMakerAppleDictionary ;

CGImageSourceCopyProperties方法返回的字典中还可能会有如下一个特殊的键:

  1. //对应文件大小
  2. const CFStringRef kCGImagePropertyFileSize;

CGImageSourceCopyPropertiesAtIndex方法中可能包含的特殊键:

  1. //像素高度
  2. const CFStringRef kCGImagePropertyPixelHeight;
  3. //像素宽度
  4. const CFStringRef kCGImagePropertyPixelWidth;
  5. //DPI高度
  6. const CFStringRef kCGImagePropertyDPIHeight;
  7. //DPI宽度
  8. const CFStringRef kCGImagePropertyDPIWidth;
  9. //颜色位数
  10. const CFStringRef kCGImagePropertyDepth;
  11. //图片的显示方向
  12. /*
  13. 对应Number值
  14. * 1 = 左上到右下.
  15. * 2 = 右上到左下.
  16. * 3 = 右下到左上.
  17. * 4 = 左下到右上.
  18. * 5 = 行列置换 左上到右下.
  19. * 6 = 行列置换 右上到左下.
  20. * 7 = 行列置换 右下到左上.
  21. * 8 = 行列置换 左下到右上.
  22. */
  23. const CFStringRef kCGImagePropertyOrientation;
  24. //颜色是否支持浮点数
  25. const CFStringRef kCGImagePropertyIsFloat;
  26. //图像是否包含像素样本
  27. const CFStringRef kCGImagePropertyIsIndexed;
  28. //图像是否包含alpha通道
  29. const CFStringRef kCGImagePropertyHasAlpha;
  30. //图像的颜色模式
  31. const CFStringRef kCGImagePropertyColorModel;
  32. //嵌入图片的ICC配置文件名称
  33. const CFStringRef kCGImagePropertyProfileName;

kCGImagePropertyColorModel键可返回的值有如下几种定义:

  1. //RBG模式
  2. const CFStringRef kCGImagePropertyColorModelRGB;
  3. //Gray模式
  4. const CFStringRef kCGImagePropertyColorModelGray;
  5. //CMYK模式
  6. const CFStringRef kCGImagePropertyColorModelCMYK;
  7. //Lab模式
  8. const CFStringRef kCGImagePropertyColorModelLab;

kCGImagePropertyTIFFDictionary键可返回的值定义如下:

  1. //图片数据压缩方案
  2. const CFStringRef kCGImagePropertyTIFFCompression;
  3. //图片数据的色彩空间
  4. const CFStringRef kCGImagePropertyTIFFPhotometricInterpretation;
  5. //文档名称
  6. const CFStringRef kCGImagePropertyTIFFDocumentName;
  7. //图片描述
  8. const CFStringRef kCGImagePropertyTIFFImageDescription;
  9. //相机设备名
  10. const CFStringRef kCGImagePropertyTIFFMake;
  11. //相机设备模式
  12. const CFStringRef kCGImagePropertyTIFFModel;
  13. //图片方向
  14. const CFStringRef kCGImagePropertyTIFFOrientation;
  15. //横向每个分辨位的像素数
  16. const CFStringRef kCGImagePropertyTIFFXResolution;
  17. //纵向每个分辨位的像素数
  18. const CFStringRef kCGImagePropertyTIFFYResolution;
  19. //分辨率单位
  20. const CFStringRef kCGImagePropertyTIFFResolutionUnit;
  21. //创建图像的软件名称和版本
  22. const CFStringRef kCGImagePropertyTIFFSoftware;
  23. //transform函数
  24. const CFStringRef kCGImagePropertyTIFFTransferFunction;
  25. //日期时间
  26. const CFStringRef kCGImagePropertyTIFFDateTime;
  27. //作者
  28. const CFStringRef kCGImagePropertyTIFFArtist;
  29. //创建图片的电脑系统
  30. const CFStringRef kCGImagePropertyTIFFHostComputer;
  31. //公司信息
  32. const CFStringRef kCGImagePropertyTIFFCopyright;
  33. //图片的白点
  34. const CFStringRef kCGImagePropertyTIFFWhitePoint;
  35. //图像的原色色度
  36. const CFStringRef kCGImagePropertyTIFFPrimaryChromaticities;
  37. //图片的瓦片宽度
  38. const CFStringRef kCGImagePropertyTIFFTileWidth;
  39. //图片的瓦片高度
  40. const CFStringRef kCGImagePropertyTIFFTileLength;

kCGImagePropertyJFIFDictionary对应的字典中可能包含如下意义的键:

  1. //JFIF版本
  2. const CFStringRef kCGImagePropertyJFIFVersion;
  3. //横向像素密度
  4. const CFStringRef kCGImagePropertyJFIFXDensity;
  5. //纵向像素密度
  6. const CFStringRef kCGImagePropertyJFIFYDensity;
  7. //像素密度单元
  8. const CFStringRef kCGImagePropertyJFIFDensityUnit;
  9. //是否是高质量图像版本
  10. const CFStringRef kCGImagePropertyJFIFIsProgressive;

kCGImagePropertyExifDictionary对应的字典中可能包含如下意义的键 :

  1. //曝光时间
  2. const CFStringRef kCGImagePropertyExifExposureTime;
  3. //ExifNumber
  4. const CFStringRef kCGImagePropertyExifFNumber;
  5. //曝光程序
  6. const CFStringRef kCGImagePropertyExifExposureProgram;
  7. //每个通道的光谱灵敏度
  8. const CFStringRef kCGImagePropertyExifSpectralSensitivity;
  9. //ISO速度等级
  10. const CFStringRef kCGImagePropertyExifISOSpeedRatings;
  11. //ExifOECF
  12. const CFStringRef kCGImagePropertyExifOECF;
  13. //灵敏类型
  14. const CFStringRef kCGImagePropertyExifSensitivityType;
  15. //输出灵敏标准
  16. const CFStringRef kCGImagePropertyExifStandardOutputSensitivity;
  17. //推荐曝光指数
  18. const CFStringRef kCGImagePropertyExifRecommendedExposureIndex;
  19. //ISO速率
  20. const CFStringRef kCGImagePropertyExifISOSpeed;
  21. const CFStringRef kCGImagePropertyExifISOSpeedLatitudeyyy;
  22. const CFStringRef kCGImagePropertyExifISOSpeedLatitudezzz;
  23. //Exif版本
  24. const CFStringRef kCGImagePropertyExifVersion;
  25. //原始日期时间
  26. const CFStringRef kCGImagePropertyExifDateTimeOriginal;
  27. //数字化日期时间
  28. const CFStringRef kCGImagePropertyExifDateTimeDigitized;
  29. //压缩配置
  30. const CFStringRef kCGImagePropertyExifComponentsConfiguration;
  31. //压缩模式像素位
  32. const CFStringRef kCGImagePropertyExifCompressedBitsPerPixel;
  33. //快门速度值
  34. const CFStringRef kCGImagePropertyExifShutterSpeedValue;
  35. //孔径值
  36. const CFStringRef kCGImagePropertyExifApertureValue;
  37. //亮度值
  38. const CFStringRef kCGImagePropertyExifBrightnessValue;
  39. //曝光偏差值
  40. const CFStringRef kCGImagePropertyExifExposureBiasValue;
  41. //最大光圈值
  42. const CFStringRef kCGImagePropertyExifMaxApertureValue;
  43. //距离
  44. const CFStringRef kCGImagePropertyExifSubjectDistance;
  45. //测光模式
  46. const CFStringRef kCGImagePropertyExifMeteringMode;
  47. //光源
  48. const CFStringRef kCGImagePropertyExifLightSource;
  49. //拍摄时的闪光状态
  50. const CFStringRef kCGImagePropertyExifFlash;
  51. //焦距
  52. const CFStringRef kCGImagePropertyExifFocalLength;
  53. //主体区域
  54. const CFStringRef kCGImagePropertyExifSubjectArea;
  55. //相机制造商指定的信息
  56. const CFStringRef kCGImagePropertyExifMakerNote;
  57. //用户信息
  58. const CFStringRef kCGImagePropertyExifUserComment;
  59. //日期和时间标记的秒分数
  60. const CFStringRef kCGImagePropertyExifSubsecTime;
  61. //原始时间
  62. const CFStringRef kCGImagePropertyExifSubsecTimeOriginal;
  63. //数字时间
  64. const CFStringRef kCGImagePropertyExifSubsecTimeDigitized;
  65. //FlashPix版本信息
  66. const CFStringRef kCGImagePropertyExifFlashPixVersion;
  67. //色彩空间
  68. const CFStringRef kCGImagePropertyExifColorSpace;
  69. //X方向像素
  70. const CFStringRef kCGImagePropertyExifPixelXDimension;
  71. //Y方向像素
  72. const CFStringRef kCGImagePropertyExifPixelYDimension;
  73. //与图像相关的声音文件
  74. const CFStringRef kCGImagePropertyExifRelatedSoundFile;
  75. //FlashEnergy
  76. const CFStringRef kCGImagePropertyExifFlashEnergy;
  77. //FrequencyResponse
  78. const CFStringRef kCGImagePropertyExifSpatialFrequencyResponse;
  79. //像素数目
  80. const CFStringRef kCGImagePropertyExifFocalPlaneXResolution;
  81. const CFStringRef kCGImagePropertyExifFocalPlaneYResolution;
  82. const CFStringRef kCGImagePropertyExifFocalPlaneResolutionUnit;
  83. //图像主体的位置
  84. const CFStringRef kCGImagePropertyExifSubjectLocation;
  85. //选择的曝光指数
  86. const CFStringRef kCGImagePropertyExifExposureIndex;
  87. //传感器类型
  88. const CFStringRef kCGImagePropertyExifSensingMethod;
  89. //图像文件源
  90. const CFStringRef kCGImagePropertyExifFileSource;
  91. //场景类型
  92. const CFStringRef kCGImagePropertyExifSceneType;
  93. //CFA模块
  94. const CFStringRef kCGImagePropertyExifCFAPattern;
  95. //对图像数据进行特殊渲染
  96. const CFStringRef kCGImagePropertyExifCustomRendered;
  97. //曝光模式设置
  98. const CFStringRef kCGImagePropertyExifExposureMode;
  99. //白平衡模式
  100. const CFStringRef kCGImagePropertyExifWhiteBalance;
  101. //数字变焦比
  102. const CFStringRef kCGImagePropertyExifDigitalZoomRatio;
  103. //35毫米胶片的等效焦距
  104. const CFStringRef kCGImagePropertyExifFocalLenIn35mmFilm;
  105. //场景捕捉类型(标准,景观,肖像,夜晚)
  106. const CFStringRef kCGImagePropertyExifSceneCaptureType;
  107. //图像增益
  108. const CFStringRef kCGImagePropertyExifGainControl;
  109. //图像对比度
  110. const CFStringRef kCGImagePropertyExifContrast;
  111. //图像饱和度
  112. const CFStringRef kCGImagePropertyExifSaturation;
  113. //图像锐度
  114. const CFStringRef kCGImagePropertyExifSharpness;
  115. //拍摄条件
  116. const CFStringRef kCGImagePropertyExifDeviceSettingDescription;
  117. //主体距离
  118. const CFStringRef kCGImagePropertyExifSubjectDistRange;
  119. //图像的唯一标识
  120. const CFStringRef kCGImagePropertyExifImageUniqueID;
  121. //相机所有者
  122. const CFStringRef kCGImagePropertyExifCameraOwnerName;
  123. //相机序列号
  124. const CFStringRef kCGImagePropertyExifBodySerialNumber;
  125. //透镜规格信息
  126. const CFStringRef kCGImagePropertyExifLensSpecification;
  127. //透镜制造商名称
  128. const CFStringRef kCGImagePropertyExifLensMake;
  129. //透镜模式
  130. const CFStringRef kCGImagePropertyExifLensModel;
  131. //透镜序列号
  132. const CFStringRef kCGImagePropertyExifLensSerialNumber;
  133. //伽马设置
  134. const CFStringRef kCGImagePropertyExifGamma;

kCGImagePropertyExifAuxDictionary对应的字典中可能包含的键定义如下:

  1. //镜头信息
  2. const CFStringRef kCGImagePropertyExifAuxLensInfo;
  3. //镜头模式
  4. const CFStringRef kCGImagePropertyExifAuxLensModel;
  5. //序列号
  6. const CFStringRef kCGImagePropertyExifAuxSerialNumber;
  7. //镜头ID
  8. const CFStringRef kCGImagePropertyExifAuxLensID;
  9. //镜头序列号
  10. const CFStringRef kCGImagePropertyExifAuxLensSerialNumber;
  11. //图片编号
  12. const CFStringRef kCGImagePropertyExifAuxImageNumber;
  13. //闪光补偿
  14. const CFStringRef kCGImagePropertyExifAuxFlashCompensation;
  15. //所有者名称
  16. const CFStringRef kCGImagePropertyExifAuxOwnerName;
  17. //固件信息
  18. const CFStringRef kCGImagePropertyExifAuxFirmware;

kCGImagePropertyGIFDictionary对应的字典中可能包含的键定义如下:

  1. //动画循环次数
  2. const CFStringRef kCGImagePropertyGIFLoopCount;
  3. //两帧之间的延时
  4. const CFStringRef kCGImagePropertyGIFDelayTime;
  5. //颜色Map
  6. const CFStringRef kCGImagePropertyGIFImageColorMap;
  7. const CFStringRef kCGImagePropertyGIFHasGlobalColorMap;
  8. //两帧之间的延时
  9. const CFStringRef kCGImagePropertyGIFUnclampedDelayTime;

kCGImagePropertyPNGDictionary对应的字典中可能包含的键定义如下:

  1. //PNG伽马值
  2. const CFStringRef kCGImagePropertyPNGGamma;
  3. //混合类型
  4. const CFStringRef kCGImagePropertyPNGInterlaceType;
  5. //X方向像素数
  6. const CFStringRef kCGImagePropertyPNGXPixelsPerMeter;
  7. //Y方向像素数
  8. const CFStringRef kCGImagePropertyPNGYPixelsPerMeter;
  9. //RGB意图
  10. const CFStringRef kCGImagePropertyPNGsRGBIntent;
  11. //色度
  12. const CFStringRef kCGImagePropertyPNGChromaticities;
  13. //作者
  14. const CFStringRef kCGImagePropertyPNGAuthor;
  15. //公司
  16. const CFStringRef kCGImagePropertyPNGCopyright;
  17. //创建时间
  18. const CFStringRef kCGImagePropertyPNGCreationTime;
  19. //描述
  20. const CFStringRef kCGImagePropertyPNGDescription;
  21. //最后修改日期时间
  22. const CFStringRef kCGImagePropertyPNGModificationTime;
  23. //软件
  24. const CFStringRef kCGImagePropertyPNGSoftware;
  25. //标题
  26. const CFStringRef kCGImagePropertyPNGTitle;
  27. //动画循环次数
  28. const CFStringRef kCGImagePropertyAPNGLoopCount;
  29. //两帧之间的延时
  30. const CFStringRef kCGImagePropertyAPNGDelayTime;
  31. const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime;

kCGImagePropertyGPSDictionary对应的字典中可能包含的键定义如下:

  1. //GPS版本
  2. const CFStringRef kCGImagePropertyGPSVersion;
  3. //纬度是南纬或北纬
  4. const CFStringRef kCGImagePropertyGPSLatitudeRef;
  5. //纬度
  6. const CFStringRef kCGImagePropertyGPSLatitude;
  7. //经度是东经或西经
  8. const CFStringRef kCGImagePropertyGPSLongitudeRef;
  9. //经度
  10. const CFStringRef kCGImagePropertyGPSLongitude;
  11. //海拔标准
  12. const CFStringRef kCGImagePropertyGPSAltitudeRef;
  13. //海拔高度
  14. const CFStringRef kCGImagePropertyGPSAltitude;
  15. //时间戳
  16. const CFStringRef kCGImagePropertyGPSTimeStamp;
  17. //测量GPS的卫星
  18. const CFStringRef kCGImagePropertyGPSSatellites;
  19. //GPS状态
  20. const CFStringRef kCGImagePropertyGPSStatus;
  21. //测量模式
  22. const CFStringRef kCGImagePropertyGPSMeasureMode;
  23. //精度数据
  24. const CFStringRef kCGImagePropertyGPSDOP;
  25. //速度标准
  26. const CFStringRef kCGImagePropertyGPSSpeedRef;
  27. //速度
  28. const CFStringRef kCGImagePropertyGPSSpeed;
  29. //运动方向参考
  30. const CFStringRef kCGImagePropertyGPSTrackRef;
  31. //运动方向
  32. const CFStringRef kCGImagePropertyGPSTrack;
  33. //位置方向参考
  34. const CFStringRef kCGImagePropertyGPSImgDirectionRef;
  35. //位置方向
  36. const CFStringRef kCGImagePropertyGPSImgDirection;
  37. //地图测量数据
  38. const CFStringRef kCGImagePropertyGPSMapDatum;
  39. //地理纬度南纬或北纬
  40. const CFStringRef kCGImagePropertyGPSDestLatitudeRef;
  41. //地理纬度
  42. const CFStringRef kCGImagePropertyGPSDestLatitude;
  43. //地理经度 东经或西经
  44. const CFStringRef kCGImagePropertyGPSDestLongitudeRef;
  45. //地理经度
  46. const CFStringRef kCGImagePropertyGPSDestLongitude;
  47. //方位参照
  48. const CFStringRef kCGImagePropertyGPSDestBearingRef;
  49. //地理方位
  50. const CFStringRef kCGImagePropertyGPSDestBearing;
  51. //距离参照
  52. const CFStringRef kCGImagePropertyGPSDestDistanceRef;
  53. //距离
  54. const CFStringRef kCGImagePropertyGPSDestDistance;
  55. //查找地理位置的方法
  56. const CFStringRef kCGImagePropertyGPSProcessingMethod;
  57. //GPS地区名
  58. const CFStringRef kCGImagePropertyGPSAreaInformation;
  59. //日期时间
  60. const CFStringRef kCGImagePropertyGPSDateStamp;
  61. //校正信息
  62. const CFStringRef kCGImagePropertyGPSDifferental;
  63. //错误信息
  64. const CFStringRef kCGImagePropertyGPSHPositioningError;

kCGImagePropertyIPTCDictionary对应的字典中可能包含的键定义如下:

  1. //对象类型
  2. const CFStringRef kCGImagePropertyIPTCObjectTypeReference;
  3. //对象属性
  4. const CFStringRef kCGImagePropertyIPTCObjectAttributeReference;
  5. //对象名称
  6. const CFStringRef kCGImagePropertyIPTCObjectName;
  7. //编辑状态
  8. const CFStringRef kCGImagePropertyIPTCEditStatus;
  9. //更新状态
  10. const CFStringRef kCGImagePropertyIPTCEditorialUpdate;
  11. //紧急等级
  12. const CFStringRef kCGImagePropertyIPTCUrgency;
  13. //主体
  14. const CFStringRef kCGImagePropertyIPTCSubjectReference;
  15. //类别
  16. const CFStringRef kCGImagePropertyIPTCCategory;
  17. //补充类别
  18. const CFStringRef kCGImagePropertyIPTCSupplementalCategory;
  19. //Fixture标识
  20. const CFStringRef kCGImagePropertyIPTCFixtureIdentifier;
  21. //关键字
  22. const CFStringRef kCGImagePropertyIPTCKeywords;
  23. //内容定位码
  24. const CFStringRef kCGImagePropertyIPTCContentLocationCode;
  25. //内容位置名称
  26. const CFStringRef kCGImagePropertyIPTCContentLocationName;
  27. //图像使用的最早日期
  28. const CFStringRef kCGImagePropertyIPTCReleaseDate;
  29. //图像使用的最早时间
  30. const CFStringRef kCGImagePropertyIPTCReleaseTime;
  31. //最后一次使用日期
  32. const CFStringRef kCGImagePropertyIPTCExpirationDate;
  33. //最后一次使用时间
  34. const CFStringRef kCGImagePropertyIPTCExpirationTime;
  35. //图像使用的特别说明
  36. const CFStringRef kCGImagePropertyIPTCSpecialInstructions;
  37. //建议行为
  38. const CFStringRef kCGImagePropertyIPTCActionAdvised;
  39. //服务参考
  40. const CFStringRef kCGImagePropertyIPTCReferenceService;
  41. //日期参考
  42. const CFStringRef kCGImagePropertyIPTCReferenceDate;
  43. //参考码
  44. const CFStringRef kCGImagePropertyIPTCReferenceNumber;
  45. //创建日期
  46. const CFStringRef kCGImagePropertyIPTCDateCreated;
  47. //创建时间
  48. const CFStringRef kCGImagePropertyIPTCTimeCreated;
  49. //数字创建日期
  50. const CFStringRef kCGImagePropertyIPTCDigitalCreationDate;
  51. //数字创建时间
  52. const CFStringRef kCGImagePropertyIPTCDigitalCreationTime;
  53. //原始程序
  54. const CFStringRef kCGImagePropertyIPTCOriginatingProgram;
  55. //程序版本
  56. const CFStringRef kCGImagePropertyIPTCProgramVersion;
  57. 图像的编辑周期(早晨,晚上或两者)。
  58. const CFStringRef kCGImagePropertyIPTCObjectCycle;
  59. //不想创建者名称
  60. const CFStringRef kCGImagePropertyIPTCByline;
  61. //图像创建标题
  62. const CFStringRef kCGImagePropertyIPTCBylineTitle;
  63. //城市信息
  64. const CFStringRef kCGImagePropertyIPTCCity;
  65. //城市内位置
  66. const CFStringRef kCGImagePropertyIPTCSubLocation;
  67. //省份
  68. const CFStringRef kCGImagePropertyIPTCProvinceState;
  69. //国家编码
  70. const CFStringRef kCGImagePropertyIPTCCountryPrimaryLocationCode;
  71. //国家名称
  72. const CFStringRef kCGImagePropertyIPTCCountryPrimaryLocationName;
  73. //OriginalTransmission参考
  74. const CFStringRef kCGImagePropertyIPTCOriginalTransmissionReference;
  75. //图像内容摘要
  76. const CFStringRef kCGImagePropertyIPTCHeadline;
  77. //提供图像服务的名称
  78. const CFStringRef kCGImagePropertyIPTCCredit;
  79. //图像源
  80. const CFStringRef kCGImagePropertyIPTCSource;
  81. //公司提示
  82. const CFStringRef kCGImagePropertyIPTCCopyrightNotice;
  83. //联系人
  84. const CFStringRef kCGImagePropertyIPTCContact;
  85. //描述
  86. const CFStringRef kCGImagePropertyIPTCCaptionAbstract;
  87. //图像编辑者
  88. const CFStringRef kCGImagePropertyIPTCWriterEditor;
  89. //图像类型
  90. const CFStringRef kCGImagePropertyIPTCImageType;
  91. //方向信息
  92. const CFStringRef kCGImagePropertyIPTCImageOrientation;
  93. //语言信息
  94. const CFStringRef kCGImagePropertyIPTCLanguageIdentifier;
  95. //星级
  96. const CFStringRef kCGImagePropertyIPTCStarRating;
  97. //联系人详细信息
  98. const CFStringRef kCGImagePropertyIPTCCreatorContactInfo;
  99. //图像使用权限
  100. const CFStringRef kCGImagePropertyIPTCRightsUsageTerms;
  101. //场景代码
  102. const CFStringRef kCGImagePropertyIPTCScene;

上面的kCGImagePropertyIPTCCreatorContactInfo对应的字典中键的定义如下:

  1. //联系人城市
  2. const CFStringRef kCGImagePropertyIPTCContactInfoCity;
  3. //联系人国家
  4. const CFStringRef kCGImagePropertyIPTCContactInfoCountry;
  5. //联系人地址
  6. const CFStringRef kCGImagePropertyIPTCContactInfoAddress;
  7. //邮编
  8. const CFStringRef kCGImagePropertyIPTCContactInfoPostalCode;
  9. //省份
  10. const CFStringRef kCGImagePropertyIPTCContactInfoStateProvince;
  11. //电子邮件
  12. const CFStringRef kCGImagePropertyIPTCContactInfoEmails;
  13. //电话
  14. const CFStringRef kCGImagePropertyIPTCContactInfoPhones;
  15. //网址
  16. const CFStringRef kCGImagePropertyIPTCContactInfoWebURLs;

kCGImageProperty8BIMDictionary对应的字典中可能包含的键定义如下:

  1. //Photoshop文件的图层名
  2. const CFStringRef kCGImageProperty8BIMLayerNames;
  3. //版本
  4. const CFStringRef kCGImageProperty8BIMVersion;

kCGImagePropertyDNGDictionary对应的字典中可能包含的键定义如下:

  1. //DNG版本
  2. const CFStringRef kCGImagePropertyDNGVersion;
  3. //兼容的最老版本
  4. const CFStringRef kCGImagePropertyDNGBackwardVersion;
  5. //摄像机模型
  6. const CFStringRef kCGImagePropertyDNGUniqueCameraModel;
  7. const CFStringRef kCGImagePropertyDNGLocalizedCameraModel;
  8. //相机序列码
  9. const CFStringRef kCGImagePropertyDNGCameraSerialNumber;
  10. //镜头信息
  11. const CFStringRef kCGImagePropertyDNGLensInfo;
  12. //黑度等级
  13. const CFStringRef kCGImagePropertyDNGBlackLevel;
  14. //白度等级
  15. const CFStringRef kCGImagePropertyDNGWhiteLevel;
  16. const CFStringRef kCGImagePropertyDNGCalibrationIlluminant1;
  17. const CFStringRef kCGImagePropertyDNGCalibrationIlluminant2;
  18. const CFStringRef kCGImagePropertyDNGColorMatrix1;
  19. const CFStringRef kCGImagePropertyDNGColorMatrix2;
  20. const CFStringRef kCGImagePropertyDNGCameraCalibration1;
  21. const CFStringRef kCGImagePropertyDNGCameraCalibration2;
  22. const CFStringRef kCGImagePropertyDNGAsShotNeutral;
  23. const CFStringRef kCGImagePropertyDNGAsShotWhiteXY;
  24. const CFStringRef kCGImagePropertyDNGBaselineExposure;
  25. const CFStringRef kCGImagePropertyDNGBaselineNoise;
  26. const CFStringRef kCGImagePropertyDNGBaselineSharpness;
  27. const CFStringRef kCGImagePropertyDNGPrivateData;
  28. const CFStringRef kCGImagePropertyDNGCameraCalibrationSignature;
  29. const CFStringRef kCGImagePropertyDNGProfileCalibrationSignature;
  30. const CFStringRef kCGImagePropertyDNGNoiseProfile;
  31. const CFStringRef kCGImagePropertyDNGWarpRectilinear;
  32. const CFStringRef kCGImagePropertyDNGWarpFisheye;
  33. const CFStringRef kCGImagePropertyDNGFixVignetteRadial;

kCGImagePropertyCIFFDictionary对应的字典中可能包含的键定义如下:

  1. //相机信息
  2. const CFStringRef kCGImagePropertyCIFFDescription;
  3. //固件版本
  4. const CFStringRef kCGImagePropertyCIFFFirmware;
  5. //所有者名称
  6. const CFStringRef kCGImagePropertyCIFFOwnerName;
  7. //图片名
  8. const CFStringRef kCGImagePropertyCIFFImageName;
  9. //图片文件名
  10. const CFStringRef kCGImagePropertyCIFFImageFileName;
  11. //曝光方式
  12. const CFStringRef kCGImagePropertyCIFFReleaseMethod;
  13. //曝光时间
  14. const CFStringRef kCGImagePropertyCIFFReleaseTiming;
  15. //RecordID
  16. const CFStringRef kCGImagePropertyCIFFRecordID;
  17. //曝光时间
  18. const CFStringRef kCGImagePropertyCIFFSelfTimingTime;
  19. //相机序列号
  20. const CFStringRef kCGImagePropertyCIFFCameraSerialNumber;
  21. //图片编码
  22. const CFStringRef kCGImagePropertyCIFFImageSerialNumber;
  23. //驱动模式
  24. const CFStringRef kCGImagePropertyCIFFContinuousDrive);
  25. //焦点模式
  26. const CFStringRef kCGImagePropertyCIFFFocusMode;
  27. //测量模式
  28. const CFStringRef kCGImagePropertyCIFFMeteringMode;
  29. //曝光模式
  30. const CFStringRef kCGImagePropertyCIFFShootingMode;
  31. //透镜模式
  32. const CFStringRef kCGImagePropertyCIFFLensModel;
  33. //最长镜头长度
  34. const CFStringRef kCGImagePropertyCIFFLensMaxMM;
  35. //最短镜头长度
  36. const CFStringRef kCGImagePropertyCIFFLensMinMM;
  37. //白平衡等级
  38. const CFStringRef kCGImagePropertyCIFFWhiteBalanceIndex;
  39. //曝光补偿
  40. const CFStringRef kCGImagePropertyCIFFFlashExposureComp;
  41. //实测曝光值
  42. const CFStringRef kCGImagePropertyCIFFMeasuredEV);

六、ImageIO框架在实际开发中的几个应用

1.显示特殊格式的图片

    在平时开发中,我们通常使用UIImage来读取图片,UIImage支持的图片包括png与jpg等,但是类似windows系统的ico图标,UIImage默认是无法显示的,可以通过ImageIO框架来在iOS系统中使用ico图标,示例如下:

  1. NSString * path = [[NSBundle mainBundle]pathForResource:@"image" ofType:@"ico"];
  2. NSURL * url = [NSURL fileURLWithPath:path];
  3. CGImageRef myImage = NULL;
  4. CGImageSourceRef myImageSource;
  5. CFDictionaryRef myOptions = NULL;
  6. myImageSource = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
  7. myImage = CGImageSourceCreateImageAtIndex(myImageSource,
  8. 0,
  9. NULL);
  10. CFRelease(myImageSource);
  11. UIImageView * image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
  12. image.image = [UIImage imageWithCGImage:myImage];
2.读取数码相机拍摄图片的地理位置、时间等信息
3.对相册中图片的地理位置,时间等信息进行自定义修改。
4.将自定义格式的图片数据写入本地文件。
5.展示GIF动图

    详情见博客:https://my.oschina.net/u/2340880/blog/608560

6.渐进渲染大图

    渐进渲染技术在对加载大图片时特别重要,你应该使用过地图软件,地图视图在加载时是局部进行加载,当移动或者放大时,地图会一部分一部分的渐进进行加载,使用ImageIO框架可以实现大图渐进渲染的效果,一般在对大图片进行网络请求时,可以获取一部分数据就加载一部分数据,为了便于演示,博客中使用定时器来默认网络返回数据,代码示例如下:

  1. @interface ViewController ()
  2. {
  3. NSMutableData * _data;
  4. NSData * _allData;
  5. NSUInteger length;
  6. UIImageView * _imageView;
  7. NSTimer * timer;
  8. NSInteger le;
  9. }
  10. @end
  11. @implementation ViewController
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. _data = [[NSMutableData alloc]init];
  15. NSString * path = [[NSBundle mainBundle]pathForResource:@"Default-Portrait-ns@2x" ofType:@"png"];
  16. _allData = [NSData dataWithContentsOfFile:path];
  17. length = _allData.length;
  18. le = length/10;
  19. timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateImage) userInfo:nil repeats:YES];
  20. _imageView = [[UIImageView alloc]initWithFrame:self.view.frame];
  21. [self.view addSubview:_imageView];
  22. }
  23. -(void)updateImage{
  24. static int index = 0;
  25. if (index==10) {
  26. return;
  27. }
  28. NSUInteger l;
  29. if (index==9) {
  30. l=length-le*9;
  31. }else{
  32. l= le;
  33. }
  34. Byte by[l];
  35. [_allData getBytes:by range:NSMakeRange(index*le, l)];
  36. [_data appendBytes:by length:l];
  37. CGImageSourceRef myImageSource = CGImageSourceCreateWithData((CFDataRef)_data, NULL);
  38. CGImageRef myImage = CGImageSourceCreateImageAtIndex(myImageSource,
  39. 0,
  40. NULL);
  41. CFRelease(myImageSource);
  42. _imageView.image = [UIImage imageWithCGImage:myImage];
  43. // image.image = [UIImage imageNamed:@"image.ico"];
  44. index++;
  45. }
  46. @end

效果如下:

   

    

转载于:https://my.oschina.net/u/2340880/blog/838680

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/912508?site
推荐阅读
相关标签
  

闽ICP备14008679号