Created
March 17, 2015 23:00
-
-
Save catehstn/abe17d87496bad0a603c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Compare two images. | |
* @param bitmap1 | |
* @param bitmap2 | |
* @return true iff both images have the same dimensions and pixel values. | |
*/ | |
public static boolean compareImages(Bitmap bitmap1, Bitmap bitmap2) { | |
if (bitmap1.getWidth() != bitmap2.getWidth() || | |
bitmap1.getHeight() != bitmap2.getHeight()) { | |
return false; | |
} | |
for (int y = 0; y < bitmap1.getHeight(); y++) { | |
for (int x = 0; x < bitmap1.getWidth(); x++) { | |
if (bitmap1.getPixel(x, y) != bitmap2.getPixel(x, y)) { | |
return false; | |
} | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment