比较UIImage [英] Comparing UIImage

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

问题描述

如何将图片与另一张图片进行比较?

How can I compare an image to another one?

谢谢!

推荐答案

如果你有两个UIImages,你应该得到他们的 CGImageRef quartz来自这些对象的表示。然后创建两个新的位图上下文,由您创建和传递的内存缓冲区支持,每个图像一个。然后使用 CGContextDrawImage 将图像绘制到位图上下文中。现在图像的字节在缓冲区中。您可以手动循环或 memcmp 来检查差异。

If you have two UIImages, you should get their CGImageRef quartz representations from those objects. Then create two new bitmap contexts backed by a memory buffer that you create and pass in, one for each of the images. Then use CGContextDrawImage to draw the images into the bitmap contexts. Now the bytes of the images are in the buffers. You can then loop through manually or memcmp to check for differences.

Apple自己的详细解释和示例代码位图上下文和绘图到这里:

Apple's own detailed explanation and sample code around creating bitmap contexts and drawing into them is here:

http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/ dq_context / dq_context.html#// apple_ref / doc / uid / TP30001066-CH203-CJBHBFFE

您的区别在于您正在绘制现有图像到上下文中。使用 CGContextDrawImage

The difference for you is that you're drawing an existing image into the context. Use CGContextDrawImage for this.

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

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