1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| public class Untitled1 {
public static void main(String[] args) {
Vector original = testImg("tf.jpg");
Vector clonde = testImg("lala/koko.jpg");
System.out.println(original.equals(clonde));
}
public static Vector testImg(String file) {
Vector all = new Vector();
try {
BufferedImage im = ImageIO.read(new FileInputStream(file));
int w = im.getWidth(null);
int h = im.getHeight(null);
int[] rgbs = new int[w * h];
int x = 0;
im.getRGB(0, 0, w, h, rgbs, 0, w);
for (int i = 0; i < w; i+=100) {
Vector line = new Vector();
for (int j = 0; j < h; j+=100) {
line.add(new Integer(rgbs[x]));
//System.out.println("Pixel " + i + "," + j + "has " +
// "RGB values of " + rgbs[x]);
x++;
}
all.add(line);
}
} catch (Exception ex) {
ex.printStackTrace();
}
return all;
}
} |
Partager