2 // The tool to compare if two images are identical or not.
5 // Copyright (C) 2015 Balthasar SzczepaĆski
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 // Requires Dev Image Library (libdevil) (http://openil.sourceforge.net/)
22 // on Pentium III libdevil must be recompiled with
23 // --disable-ssl2 --disable-ssl3
24 // (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572954)
35 int mustard(const char *t,int m,int e);
36 int main(int argc, char *argv[]);
38 ILuint inpix1, inpix2;
41 int main(int argc, char *argv[])
44 ILubyte *data1, *data2;
46 ILuint x1, x2, y1, y2;
50 return mustard("compare inpix1 inpix2 ",0,FAIL);
56 ilEnable(IL_ORIGIN_SET);
57 ilEnable(IL_FILE_OVERWRITE);
59 ilGenImages(1,&inpix1);
60 ilGenImages(1,&inpix2);
63 if(!ilLoadImage(argv[1]))
64 return mustard("inpix1 load fail.",1,FAIL);
65 if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))
66 return mustard("inpix1 convert fail.",1,FAIL);
68 x1=ilGetInteger(IL_IMAGE_WIDTH);
69 y1=ilGetInteger(IL_IMAGE_HEIGHT);
73 if(!ilLoadImage(argv[2]))
74 return mustard("inpix2 load fail.",1,FAIL);
75 if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))
76 return mustard("inpix2 convert fail.",1,FAIL);
78 x2=ilGetInteger(IL_IMAGE_WIDTH);
80 return mustard("different size.",1,DIFF_SIZE);
81 y2=ilGetInteger(IL_IMAGE_HEIGHT);
83 return mustard("different size.",1,DIFF_SIZE);
90 if(data1[i]!=data2[i])
91 return mustard("different pixels.",1,DIFF_PIX);
93 return mustard("identical.",1,SAME);
96 int mustard(const char *t, int m,int e)
102 ilDeleteImages(1,&inpix1);
103 ilDeleteImages(1,&inpix2);