2 // The tool to see difference between two images hidden iside one indexed image
\r
5 // Copyright (C) 2015 Balthasar Szczepański
\r
7 // This program is free software: you can redistribute it and/or modify
\r
8 // it under the terms of the GNU Affero General Public License as
\r
9 // published by the Free Software Foundation, either version 3 of the
\r
10 // License, or (at your option) any later version.
\r
12 // This program is distributed in the hope that it will be useful,
\r
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 // GNU Affero General Public License for more details.
\r
17 // You should have received a copy of the GNU Affero General Public License
\r
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
21 // Requires Dev Image Library (libdevil) (http://openil.sourceforge.net/)
\r
22 // on Pentium III libdevil must be recompiled with
\r
23 // --disable-ssl2 --disable-ssl3
\r
24 // (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572954)
\r
26 //#include <stdlib.h>
\r
30 int mustard(const char *t,int m,int e);
\r
31 int main(int argc, char *argv[]);
\r
32 //unsigned short psqrt(unsigned short s);
\r
33 unsigned short tsqrt(unsigned short s);
\r
35 ILuint inpix, outpix;
\r
38 int main(int argc, char *argv[])
\r
41 ILubyte *pal, *data1, *data;
\r
42 ILubyte pal12[16*3];
\r
45 ILuint col12, col, x, y;
\r
48 return mustard("seediff inpix outpix [q]",0,1);
\r
53 ilEnable(IL_ORIGIN_SET);
\r
54 ilEnable(IL_FILE_OVERWRITE);
\r
56 ilGenImages(1,&inpix);
\r
57 ilGenImages(1,&outpix);
\r
60 if(!ilLoadImage(argv[1]))
\r
61 return mustard("inpix load fail.",1,1);
\r
62 if(ilGetInteger(IL_IMAGE_FORMAT)!=IL_COLOUR_INDEX)
\r
63 return mustard("inpix not indexed.",1,1);
\r
64 ilConvertPal(IL_PAL_RGB24);
\r
65 col=ilGetInteger(IL_PALETTE_NUM_COLS);
\r
68 return mustard("Palette is not squarish.",1,1);
\r
69 x=ilGetInteger(IL_IMAGE_WIDTH);
\r
70 y=ilGetInteger(IL_IMAGE_HEIGHT);
\r
74 for(i=0;i<col12;++i)
\r
76 pal12[3*i ]=pal[3*i*(col12+1) ];
\r
77 pal12[3*i+1]=pal[3*i*(col12+1)+1];
\r
78 pal12[3*i+2]=pal[3*i*(col12+1)+2];
\r
81 ilBindImage(outpix);
\r
82 if(!ilTexImage(x,y,1,1,IL_COLOUR_INDEX,IL_UNSIGNED_BYTE,NULL))
\r
83 return mustard ("outpix create fail.",1,1);
\r
84 ilRegisterPal(pal12,col12*3,IL_PAL_RGB24);
\r
91 data1[k]=(data[k]/col12)^(data[k]%col12);
\r
94 if(!ilSave(IL_PNG,argv[2]))
\r
95 return mustard("outpix save fail",1,1);
\r
97 return mustard("Ok",1,0);
\r
102 int mustard(const char *t, int m,int e)
\r
109 ilDeleteImages(1,&inpix);
\r
110 ilDeleteImages(1,&outpix);
\r
117 unsigned short tsqrt(unsigned short s)
\r
157 //unsigned short isqrt(unsigned s)
\r
159 // unsigned short r;
\r
160 // unsigned short b=0x0040;
\r