如何比较两个UIImage对象 [英] How to compare two UIImage objects

查看:86
本文介绍了如何比较两个UIImage对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序。在我更改 UIImageview 图像之前,我正在使用 imageviews .SO需要在 UIimage obejct中获取该图像,并与另一个 UIImage 对象进行比较以查找是否为sam。所以请告诉我如何做到这一点。

I am developing one application.In that i am using the imageviews.SO before changeing the UIImageview image I need to take that image in UIimage obejct and compare with another UIImage object for finding both are sam or not. So please tell me how to do that one.

推荐答案

一种方法是首先将它们转换为图像数据,然后比较。

One way is to convert them to image data first, and then compare that.

- (BOOL)image:(UIImage *)image1 isEqualTo:(UIImage *)image2
{
    NSData *data1 = UIImagePNGRepresentation(image1);
    NSData *data2 = UIImagePNGRepresentation(image2);

    return [data1 isEqual:data2];
}

这篇关于如何比较两个UIImage对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆