How can I compare an image to another one?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you have two UIImages, you should get their
CGImageRefquartz 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 useCGContextDrawImageto draw the images into the bitmap contexts. Now the bytes of the images are in the buffers. You can then loop through manually ormemcmpto check for differences.Apple’s own detailed explanation and sample code around creating bitmap contexts and drawing into them is here:
https://developer.apple.com/library/content/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_context/dq_context.html
The difference for you is that you’re drawing an existing image into the context. Use
CGContextDrawImagefor this.