So, I'm using a file sharing app on Android. It creates a duplicate copy which is uploaded to it's server.
PROBLEM
The following code works for a duplicate copy I manually create. That is, I long press and copy the file into the same directory with a File Manager. Then my function returns true
. When it compares the duplicate image due to the app and the original image, I get false
.
MD5-checksums are different so that is out of the options.
CODE
public boolean equals(Bitmap bitmap1, Bitmap bitmap2) {
ByteBuffer buffer1 = ByteBuffer.allocate(bitmap1.getHeight()
* bitmap1.getRowBytes());
bitmap1.copyPixelsToBuffer(buffer1);
ByteBuffer buffer2 = ByteBuffer.allocate(bitmap2.getHeight()
* bitmap2.getRowBytes());
bitmap2.copyPixelsToBuffer(buffer2);
return Arrays.equals(buffer1.array(), buffer2.array());
}
Here are the images :
Duplicate image created by the app -
My code currently returns false while comparing these two images. How do I get the code to return true?