]> bicyclesonthemoon.info Git - ott/enhance/blob - 403.cpp
back to npb
[ott/enhance] / 403.cpp
1     //  //It's 403fication Time!
2    //  // Take a picture and add a Megan to it!
3   //  //  
4  //  //   Requires Dev Image Library,
5 //  //  //on Pentium III libdevil must be
6    //  // recompiled with --disable-ssl2 --disable-ssl3
7   //  //
8  //  //   ~~bicyclesonthemoon
9
10 #define INPIX_MUSTARD 1
11 #define OUTPIX_MUSTARD 2
12 #define MEGPIX_MUSTARD 3
13 #define ARGUMENT_MUSTARD 4
14 #define SEAISH_MUSTARD 5
15 #define ANIMATED_MUSTARD 6
16 #define FAIL 900
17 #define OK 0
18
19 #define MEGPIX "403.png"
20 #define XM 553
21 #define XA 262
22 #define XB 226
23 #define YM 395
24 #define YA 131
25
26 /*#define NPBPIX0 "npb0.png"
27 #define X0  411
28 #define X01  21
29 #define X02  96
30 #define Y0  404
31 #define Y01 214
32 #define Y02  68
33
34 #define NPBPIX1 "npb1.png"
35 #define X1  411
36 #define X11  22
37 #define X12 133
38 #define Y1  404
39 #define Y11 241
40 #define Y12  94
41
42 #define NPBPIX2 "npb2.png"
43 #define X2  411
44 #define X21 213
45 #define Y2  404
46 #define Y21 234*/
47
48 #include <stdlib.h>
49 #include <stdio.h>
50 #include <IL/il.h>
51
52 void mustard(int mustard);
53 void loadmeg(const char *path);
54 void m403(const char *path);
55 int main (int argc, const char *argv[]);
56
57 ILuint inPix, outPix, megPix;
58 ILboolean q=true;
59 ILboolean inH=false;
60 ILboolean outH=false;
61 ILboolean megH=false;
62 ILuint inX, inY, outX, outY;
63 ILubyte *newdata;
64
65 int main (int argc, const char *argv[])
66 {
67         if(argc<3)
68                 mustard(ARGUMENT_MUSTARD);
69         if (argc>=4)
70         {
71                 if (argv[3][0]=='q' || argv[3][0]=='Q')
72                         q=false;
73         }
74         
75         ilInit();
76         if(!ilEnable(IL_ORIGIN_SET))mustard(FAIL);
77         if(!ilEnable(IL_FILE_OVERWRITE))mustard(FAIL);
78         ilClearColour(255,255,255,255);
79         ilGenImages(1, &inPix);
80         inH=true;
81         ilBindImage(inPix);
82         if(!ilLoadImage(argv[1]))mustard(INPIX_MUSTARD);
83         if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(INPIX_MUSTARD);
84         //if(!ilConvertPal(IL_PAL_RGBA32))mustard(FAIL);
85         
86         inX=ilGetInteger(IL_IMAGE_WIDTH);
87         inY=ilGetInteger(IL_IMAGE_HEIGHT);
88         if(ilGetInteger(IL_NUM_IMAGES)>1)
89                 mustard(ANIMATED_MUSTARD);
90         
91         m403(argv[2]);
92         //ok
93         mustard(0);
94 }
95
96 void loadmeg(const char *path)
97 {
98         ilGenImages(1, &megPix);
99         megH=true;
100         ilBindImage(megPix);
101         if(!ilLoadImage(path))mustard(MEGPIX_MUSTARD);
102         if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(MEGPIX_MUSTARD);
103 }
104
105 void m403(const char *path)
106 {
107         unsigned long i,j;
108         outX=(inX+XB+6>XM)?(inX+XB+6):XM;
109         outY=(inY+YA+6>YM)?(inY+YA+6):YM;
110         ilGenImages(1, &outPix);
111         outH=true;
112         loadmeg(MEGPIX);
113         newdata=ilGetData();
114         ilBindImage(outPix);
115         if(!ilTexImage(outX,outY,1,4,IL_RGBA,IL_UNSIGNED_BYTE,NULL))mustard(OUTPIX_MUSTARD);
116         if(!ilClearImage())mustard(FAIL);
117         
118         ilSetPixels(0,0/**/,0,XM,YM,1,IL_RGBA,IL_UNSIGNED_BYTE,newdata);
119         if(!ilOverlayImage(inPix,((inX/2<XA-XB)?(XA-inX/2):XB),outY-YA-inY,0))mustard(FAIL);
120         
121         newdata=ilGetData();
122         
123         for(i=0;i<outX;++i)
124         {
125                 newdata[4*(i              )  ]=0x00;
126                 newdata[4*(i              )+1]=0x00;
127                 newdata[4*(i              )+2]=0x00;
128                 newdata[4*(i              )+3]=0xFF;
129                 
130                 newdata[4*(i+outX         )  ]=0x00;
131                 newdata[4*(i+outX         )+1]=0x00;
132                 newdata[4*(i+outX         )+2]=0x00;
133                 newdata[4*(i+outX         )+3]=0xFF;
134         
135                 newdata[4*(i+outX*(outY-1))  ]=0x00;
136                 newdata[4*(i+outX*(outY-1))+1]=0x00;
137                 newdata[4*(i+outX*(outY-1))+2]=0x00;
138                 newdata[4*(i+outX*(outY-1))+3]=0xFF;
139                 
140                 newdata[4*(i+outX*(outY-2))  ]=0x00;
141                 newdata[4*(i+outX*(outY-2))+1]=0x00;
142                 newdata[4*(i+outX*(outY-2))+2]=0x00;
143                 newdata[4*(i+outX*(outY-2))+3]=0xFF;
144         }
145                 
146         for(j=2;j<outY-2;++j)
147         {
148                 newdata[4*(       outX*j)  ]=0x00;
149                 newdata[4*(       outX*j)+1]=0x00;
150                 newdata[4*(       outX*j)+2]=0x00;
151                 newdata[4*(       outX*j)+3]=0xFF;
152                 
153                 newdata[4*(     1+outX*j)  ]=0x00;
154                 newdata[4*(     1+outX*j)+1]=0x00;
155                 newdata[4*(     1+outX*j)+2]=0x00;
156                 newdata[4*(     1+outX*j)+3]=0xFF;
157                 
158                 newdata[4*(outX-1+outX*j)  ]=0x00;
159                 newdata[4*(outX-1+outX*j)+1]=0x00;
160                 newdata[4*(outX-1+outX*j)+2]=0x00;
161                 newdata[4*(outX-1+outX*j)+3]=0xFF;
162                 
163                 
164         }
165         
166         newdata[4*(outX-1+outX*(outY-1))  ]=0xB6;
167         newdata[4*(outX-1+outX*(outY-1))+1]=0xB6;
168         newdata[4*(outX-1+outX*(outY-1))+2]=0xB6;
169         newdata[4*(outX-1+outX*(outY-1))+3]=0xFF;
170         
171         newdata[4*(       outX*(outY-1))  ]=0xB6;
172         newdata[4*(       outX*(outY-1))+1]=0xB6;
173         newdata[4*(       outX*(outY-1))+2]=0xB6;
174         newdata[4*(       outX*(outY-1))+3]=0xFF;
175         
176         newdata[4*(outX-1              )  ]=0xB6;
177         newdata[4*(outX-1              )+1]=0xB6;
178         newdata[4*(outX-1              )+2]=0xB6;
179         newdata[4*(outX-1              )+3]=0xFF;
180         
181         newdata[                         0]=0xB6;
182         newdata[                         1]=0xB6;
183         newdata[                         2]=0xB6;
184         newdata[                         3]=0xFF;
185         
186         if(!ilSave(IL_PNG,path))mustard(OUTPIX_MUSTARD);
187 }
188
189 /*void npbottify2(const char *path)
190 {
191
192         
193         for(i=outX-X21-inX-2;i<outX-X21+2;++i)
194         {
195                 //printf("i=%lu\n",i);
196                 for(j=Y21-2;j<Y21+inY+2;++j)
197                 {
198                         //printf("i=%lu j=%lu\n",i,j);
199                         if((i==outX-X21-inX-2)||(i==outX-X21-inX-1)||
200                            (i==outX-X21    +1)||(i==outX-X21      )||
201                            (j==     Y21    -2)||(j==     Y21    -1)||
202                            (j==     Y21+inY+1)||(j==     Y21+inY  ))
203                         {
204                                 newdata[4*(i+outX*j)+0]=0x00;
205                                 newdata[4*(i+outX*j)+1]=0x00;
206                                 newdata[4*(i+outX*j)+2]=0x00;
207                                 newdata[4*(i+outX*j)+3]=0xFF;   
208                         }
209                         else
210                         {
211                                 newdata[4*(i+outX*j)+0]=0xFF;
212                                 newdata[4*(i+outX*j)+1]=0xFF;
213                                 newdata[4*(i+outX*j)+2]=0xFF;
214                                 newdata[4*(i+outX*j)+3]=0xFF;
215                         }
216                 }
217         }
218         
219         
220         //
221         
222         
223         i=outX-X21-inX-2;
224         j=Y21-2;
225         newdata[4*(i+outX*j)+0]=0x00;
226         newdata[4*(i+outX*j)+1]=0x00;
227         newdata[4*(i+outX*j)+2]=0x00;
228         newdata[4*(i+outX*j)+3]=0x00;   
229         j=Y21+inY+1;
230         newdata[4*(i+outX*j)+0]=0x00;
231         newdata[4*(i+outX*j)+1]=0x00;
232         newdata[4*(i+outX*j)+2]=0x00;
233         newdata[4*(i+outX*j)+3]=0x00;   
234         i=outX-X21+1;
235         newdata[4*(i+outX*j)+0]=0x00;
236         newdata[4*(i+outX*j)+1]=0x00;
237         newdata[4*(i+outX*j)+2]=0x00;
238         newdata[4*(i+outX*j)+3]=0x00;   
239         j=Y21-2;
240         newdata[4*(i+outX*j)+0]=0x00;
241         newdata[4*(i+outX*j)+1]=0x00;
242         newdata[4*(i+outX*j)+2]=0x00;
243         newdata[4*(i+outX*j)+3]=0x00;   
244         
245         i=outX-X21-inX;
246         j=Y21;
247         newdata[4*(i+outX*j)+0]=0x00;
248         newdata[4*(i+outX*j)+1]=0x00;
249         newdata[4*(i+outX*j)+2]=0x00;
250         newdata[4*(i+outX*j)+3]=0xFF;   
251         j=Y21+inY-1;
252         newdata[4*(i+outX*j)+0]=0x00;
253         newdata[4*(i+outX*j)+1]=0x00;
254         newdata[4*(i+outX*j)+2]=0x00;
255         newdata[4*(i+outX*j)+3]=0xFF;   
256         i=outX-X21-1;
257         newdata[4*(i+outX*j)+0]=0x00;
258         newdata[4*(i+outX*j)+1]=0x00;
259         newdata[4*(i+outX*j)+2]=0x00;
260         newdata[4*(i+outX*j)+3]=0xFF;   
261         j=Y21;
262         newdata[4*(i+outX*j)+0]=0x00;
263         newdata[4*(i+outX*j)+1]=0x00;
264         newdata[4*(i+outX*j)+2]=0x00;
265         newdata[4*(i+outX*j)+3]=0xFF;
266         
267         
268
269         
270 }*/
271
272 void mustard(int mustard)
273 {
274         switch(mustard)
275         {
276         case 0:
277                 if(q) printf("403fied!\n");break;
278         case ARGUMENT_MUSTARD:
279                 if(q) printf("npb inPix outPix [q]\n");break;
280         case INPIX_MUSTARD:
281                 if(q) printf("inPIX mustard.\n");break;
282         case OUTPIX_MUSTARD:
283                 if(q) printf("outPIX mustard.\n");break;
284         case MEGPIX_MUSTARD:
285                 if(q) printf("megPIX mustard.\n");break;
286         case SEAISH_MUSTARD:
287                 if(q) printf("Seaishness is mustard.\n");break;
288         case ANIMATED_MUSTARD:
289                 if(q) printf("Animation is mustard.\n");break;
290         default:
291                 if (q) printf("Ch*rpin* mustard mustaard!\n");
292         }
293         if(inH)
294                 ilDeleteImages(1, &inPix);
295         if(outH)
296         {
297                 ilDeleteImages(1, &outPix);
298                 //delete[] newdata;
299         }
300         if(megH)
301                 ilDeleteImages(1, &megPix);
302         exit(mustard);
303 }
304