Well, if you want to compare two byte arrays, you need to have two byte arrays to compare. So, you need at least two buffers.
The byte arrays you have are probably JPEG data streams. I'm not sure how useful it is to compare them in this format. You might be better off to have the raw pixel data.
Code:
int width = img.getWidth();
int height = img.getHeight();
int[] pixels = new int[width * height];
img.getRGB(pixels, 0, width, 0, 0, width, height);
Each int in the array is a 32 bit ARGB value for a single pixel.
You can compare to int[] easily:
Code:
private static boolean areIdentical(int[] a, int[] b) {
boolean same;
if (a.length != b.length) {
same = false;
} else {
same = true;
int i = 0;
while (same && i < a.length) {
if (a[i] != b[i]) {
same = false;
}
i++;
}
}
return same;
}
However, this will tell you only whether or not two images are
identical. A slight fluctuation in lighting would cause even the smallest difference, and the two images would not be identical (even if they look the same to human eyes).
You might want to think about how much difference between two images you want to detect.
Graham.