获取UIImage的图像MD5
来源:互联网 发布:高斯混合模型 知乎 编辑:程序博客网 时间:2024/06/06 08:39
问:
I'm trying to compare two UIImages from the file system to see if they are the same. Obviously, I can't use NSObject's hash method, since this returns a hash of the object, and not the actual image data.
I found code generate an MD5 hash from a string, but I haven't discovered how to implement it for a UIImage.
How should I go about hashing a UIImage? Or is my method for comparing to images totally off?
回答:
I wound up using the following code to accomplish the task.
Note that this requires that you import<CommonCrypto/CommonDigest.h>
:
unsigned char result[16];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(inImage)];
CC_MD5(imageData, [imageData length], result);
NSString *imageHash = [NSString stringWithFormat: @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15] ];
- 获取UIImage的图像MD5
- UIImage获取灰度图像
- 获取渐变的UIImage
- UIImage 图像
- UIImage转Md5
- 获取文件的md5
- MD5值的获取
- 获取文件的md5
- 获取文件的MD5
- 获取文件的md5
- 获取文件的MD5
- ios 获取UIImage图片的像素尺寸
- Spark-MD5获取文件MD5的使用
- Cocoa UIImage 加载图像
- UIImage图像--IOS开发
- UIImage图像旋转
- UIImage图像操作
- UIImage 图像处理
- CString 操作指南
- Android 面试题积累
- Android 2.3 代码混淆proguard技术介绍
- struts2.0.6 + tiles 使用配置过程
- iphone开发 UINavigationBar贴图
- 获取UIImage的图像MD5
- 怎样提高自己的内涵、气质
- forward与get/post请求方式-重庆的那孩子的问题
- 关于mysql的密码
- HTTP请求(GET与POST区别)和响应
- js中定义正则表达式
- Android的根证书颁发机构列表
- 强制释放windows下面的端口(ZT)
- SQL Server 2008 BCP工具