#define FAIL 900
#define OK 0
-//npb0.png
+#define NPBPIX0 "npb0.png"
#define X0 411
#define X01 21
#define X02 96
#define Y01 214
#define Y02 68
-//npb1.png
+#define NPBPIX1 "npb1.png"
#define X1 411
#define X11 22
#define X12 133
#define Y11 241
#define Y12 94
-#define NPBPIX0 "npb0.png"
-#define NPBPIX1 "npb1.png"
+#define NPBPIX2 "npb2.png"
+#define X2 411
+#define X21 213
+#define Y2 404
+#define Y21 234
#include <stdlib.h>
#include <stdio.h>
#include <IL/il.h>
+
void mustard(int mustard);
void loadnpb(const char *path);
void npbottify0(const char *path);
void npbottify1(const char *path);
+void npbottify2(const char *path);
int main (int argc, const char *argv[]);
ILuint inPix, outPix, npbPix;
ILboolean inH=false;
ILboolean outH=false;
ILboolean npbH=false;
-ILuint inX, inY;
+ILuint inX, inY, outX, outY;
ILubyte *newdata;
int main (int argc, const char *argv[])
ilInit();
if(!ilEnable(IL_ORIGIN_SET))mustard(FAIL);
if(!ilEnable(IL_FILE_OVERWRITE))mustard(FAIL);
- ilClearColour(0,0,0,0);
+ ilClearColour(255,255,0,0);
ilGenImages(1, &inPix);
inH=true;
ilBindImage(inPix);
else if(inX<=X12&&inY<=Y12)
npbottify1(argv[2]);
else
- mustard(SEAISH_MUSTARD);
-
+ npbottify2(argv[2]);
//ok
mustard(0);
}
if(!ilSave(IL_PNG,path))mustard(OUTPIX_MUSTARD);
}
+void npbottify2(const char *path)
+{
+ unsigned long i,j;
+ outX=(X21+inX+2>X2)?(X21+inX+2):X2;
+ outY=(Y21+inY+2>Y2)?(Y21+inY+2):Y2;
+ ilGenImages(1, &outPix);
+ outH=true;
+ loadnpb(NPBPIX2);
+ newdata=ilGetData();
+ ilBindImage(outPix);
+ if(!ilTexImage(outX,outY,1,4,IL_RGBA,IL_UNSIGNED_BYTE,NULL))mustard(OUTPIX_MUSTARD);
+ if(!ilClearImage())mustard(FAIL);
+ ilSetPixels(outX-X2,0,0,X2,Y2,1,IL_RGBA,IL_UNSIGNED_BYTE,newdata);
+ newdata=ilGetData();
+ for(i=outX-X21-inX-2;i<outX-X21+2;++i)
+ {
+ //printf("i=%lu\n",i);
+ for(j=Y21-2;j<Y21+inY+2;++j)
+ {
+ //printf("i=%lu j=%lu\n",i,j);
+ if((i==outX-X21-inX-2)||(i==outX-X21-inX-1)||
+ (i==outX-X21 +1)||(i==outX-X21 )||
+ (j== Y21 -2)||(j== Y21 -1)||
+ (j== Y21+inY+1)||(j== Y21+inY ))
+ {
+ newdata[4*(i+outX*j)+0]=0x00;
+ newdata[4*(i+outX*j)+1]=0x00;
+ newdata[4*(i+outX*j)+2]=0x00;
+ newdata[4*(i+outX*j)+3]=0xFF;
+ }
+ else
+ {
+ newdata[4*(i+outX*j)+0]=0xFF;
+ newdata[4*(i+outX*j)+1]=0xFF;
+ newdata[4*(i+outX*j)+2]=0xFF;
+ newdata[4*(i+outX*j)+3]=0xFF;
+ }
+ }
+ }
+
+ if(!ilOverlayImage(inPix,outX-X21-inX,outY-Y21-inY,0))mustard(FAIL);
+
+ i=outX-X21-inX-2;
+ j=Y21-2;
+ newdata[4*(i+outX*j)+0]=0x00;
+ newdata[4*(i+outX*j)+1]=0x00;
+ newdata[4*(i+outX*j)+2]=0x00;
+ newdata[4*(i+outX*j)+3]=0x00;
+ j=Y21+inY+1;
+ newdata[4*(i+outX*j)+0]=0x00;
+ newdata[4*(i+outX*j)+1]=0x00;
+ newdata[4*(i+outX*j)+2]=0x00;
+ newdata[4*(i+outX*j)+3]=0x00;
+ i=outX-X21+1;
+ newdata[4*(i+outX*j)+0]=0x00;
+ newdata[4*(i+outX*j)+1]=0x00;
+ newdata[4*(i+outX*j)+2]=0x00;
+ newdata[4*(i+outX*j)+3]=0x00;
+ j=Y21-2;
+ newdata[4*(i+outX*j)+0]=0x00;
+ newdata[4*(i+outX*j)+1]=0x00;
+ newdata[4*(i+outX*j)+2]=0x00;
+ newdata[4*(i+outX*j)+3]=0x00;
+
+ i=outX-X21-inX;
+ j=Y21;
+ newdata[4*(i+outX*j)+0]=0x00;
+ newdata[4*(i+outX*j)+1]=0x00;
+ newdata[4*(i+outX*j)+2]=0x00;
+ newdata[4*(i+outX*j)+3]=0xFF;
+ j=Y21+inY-1;
+ newdata[4*(i+outX*j)+0]=0x00;
+ newdata[4*(i+outX*j)+1]=0x00;
+ newdata[4*(i+outX*j)+2]=0x00;
+ newdata[4*(i+outX*j)+3]=0xFF;
+ i=outX-X21-1;
+ newdata[4*(i+outX*j)+0]=0x00;
+ newdata[4*(i+outX*j)+1]=0x00;
+ newdata[4*(i+outX*j)+2]=0x00;
+ newdata[4*(i+outX*j)+3]=0xFF;
+ j=Y21;
+ newdata[4*(i+outX*j)+0]=0x00;
+ newdata[4*(i+outX*j)+1]=0x00;
+ newdata[4*(i+outX*j)+2]=0x00;
+ newdata[4*(i+outX*j)+3]=0xFF;
+
+ if(!ilSave(IL_PNG,path))mustard(OUTPIX_MUSTARD);
+
+
+}
void mustard(int mustard)
{