UIImageJPEGRepresentation和UIImagePNGRepresentation的比较
来源:互联网 发布:阿里云香港如何使用cdn 编辑:程序博客网 时间:2024/04/27 19:16
在Iphone上有两种读取图片数据的简单方法: UIImageJPEGRepresentation和UIImagePNGRepresentation.
UIImageJPEGRepresentation函数需要两个参数:图片的引用和压缩系数.
而UIImagePNGRepresentation只需要图片引用作为参数.
通过在实际使用过程中,比较发现:
UIImagePNGRepresentation(UIImage* image) 要比UIImageJPEGRepresentation(UIImage* image, 1.0) 返回的图片数据量大很多.
譬如,同样是读取摄像头拍摄的同样景色的照片, UIImagePNGRepresentation()返回的数据量大小为199K ,而 UIImageJPEGRepresentation(UIImage* image, 1.0)返回的数据量大小只为140KB,比前者少了50多KB.
如果对图片的清晰度要求不高,还可以通过设置 UIImageJPEGRepresentation函数的第二个参数,大幅度降低图片数据量.
譬如,刚才拍摄的图片, 通过调用UIImageJPEGRepresentation(UIImage* image, 1.0)读取数据时,返回的数据大小为140KB,但更改压缩系数后,通过调用UIImageJPEGRepresentation(UIImage* image, 0.5)读取数据时,返回的数据大小只有11KB多,大大压缩了图片的数据量 ,而且从视角角度看,图片的质量并没有明显的降低.因此,在读取图片数据内容时,建议优先使用UIImageJPEGRepresentation,并可根据自己的实际使用场景,设置压缩系数,进一步降低图片数据量大小.
- UIImageJPEGRepresentation和UIImagePNGRepresentation的比较
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- UIImageJPEGRepresentation和UIImagePNGRepresentation
- Eclipse快捷键 最有用的快捷键
- Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/
- linux-2.6.32内核LCD驱动移植-1
- 策略模式
- jQuery.extend 函数详解
- UIImageJPEGRepresentation和UIImagePNGRepresentation的比较
- OpenCV 学习笔记1
- 几种排序算法java实现
- 希望这一天能成为一个纪念日
- 【nginx】反向代理和正向代理
- 关于AsyncTask与Handler
- Android中AyncTask线程终止问题
- POJ 2492 A Bug's Life
- css reset