1. Make sure the height matches if it doesn't return false. Then check if the width matches, and if not, return false. Then check each pixel until you find one that doesn't match. When you do, return false. If each pixel matches, return true.
pseudo code:
bool imagesAreEqual(Image i1, Image i2) { if (i1.getHeight() != i2.getHeight()) return false; if (i1.getWidth() != i2.getWidth()) return false; for (int y = 0; y < i1.getHeight(); ++y) for (int x = 0; x < i1.getWidth(); ++x) if (i1.getPixel(x, y) != i2.getPixel(x, y)) return false; return true; }
in fact, you probably want to treat the image as a two-dimensional array if you can, and just compare the bytes. I don't know the image API for Android, but getPixel can be slow.
2. Perhaps you convert images to byte64 strings and then compare them.
3. * * OpenCV lib for Android:
have functions for compressing images
** a. Core.absdiff() b. Core.compare()
For more details see comparison of two images.
ρσѕρє K
source share