How can I compare an image to another one?
Thanks!
How can I compare an image to another one?
Thanks!
Your best bet is to get a CGImage from UIImage and than use CGImageGetDecode to get the raw data and compare that.
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's own detailed explanation and sample code around creating bitmap contexts and drawing into them is here:
The difference for you is that you're drawing an existing image into the context. Use CGContextDrawImage for this.