2 // // ENHANCE the bluepix!
4 // // Requires Dev Image Library,
5 // // //on Pentium III libdevil must be
6 // // recompiled with --disable-ssl2 --disable-ssl3
8 // // ~~bicyclesonthemoon
10 #define INPIX_MUSTARD 1
11 #define OUTPIX_MUSTARD 2
13 #define ARGUMENT_MUSTARD 4
15 #define ANIMATED_MUSTARD 6
19 #define CR newdata[4*(i+inX*j)+0]
20 #define CG newdata[4*(i+inX*j)+1]
21 #define CB newdata[4*(i+inX*j)+2]
34 void mustard(int mustard);
35 ILubyte enhance(ILubyte x, long r, long s, long t);
36 ILubyte enhance2(ILubyte x, ILubyte a, ILubyte b, ILubyte c, ILubyte d, ILubyte e, ILubyte f);
37 ILubyte enhance3(ILubyte x, ILubyte a, ILubyte b, ILubyte c);
38 int main (int argc, const char *argv[]);
42 ILboolean pixOpen=false;
45 ILubyte enhance(ILubyte x, long r, long s, long t)
48 return (ILubyte)((y>255)?255:((y<0)?0:y));
51 ILubyte enhance2(ILubyte x, ILubyte a, ILubyte b, ILubyte c, ILubyte d, ILubyte e, ILubyte f)
53 return ((x<=a)?d:((x>=c)?f:((x>b)?(enhance(x,F-E,C-B,E*C-B*F)):((x<b)?(enhance(x,E-D,B-A,D*B-A*E)):e))));
56 ILubyte enhance3(ILubyte x, ILubyte a, ILubyte b, ILubyte c)
58 return enhance(x,C-A,B-A,(B-C)*A);
61 int main (int argc, const char *argv[])
63 ILubyte a,b,c,d,e,f,g;
69 mustard(ARGUMENT_MUSTARD);
72 if (argv[9][0]=='q' || argv[9][0]=='Q')
76 sscanf(argv[3],"%hhu",&a);
77 sscanf(argv[4],"%hhu",&b);
78 sscanf(argv[5],"%hhu",&c);
79 sscanf(argv[6],"%hhu",&d);
80 sscanf(argv[7],"%hhu",&e);
81 sscanf(argv[8],"%hhu",&f);
84 if(!ilEnable(IL_ORIGIN_SET))mustard(FAIL);
85 if(!ilEnable(IL_FILE_OVERWRITE))mustard(FAIL);
86 ilClearColour(255,255,0,0);
90 if(!ilLoadImage(argv[1]))mustard(INPIX_MUSTARD);
91 if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(INPIX_MUSTARD);
93 inX=ilGetInteger(IL_IMAGE_WIDTH);
94 inY=ilGetInteger(IL_IMAGE_HEIGHT);
95 if(ilGetInteger(IL_NUM_IMAGES)>1)
96 mustard(ANIMATED_MUSTARD);
99 for(unsigned long i=0;i<inX;++i)
101 for(unsigned long j=0;j<inY;++j)
105 //it'll stilll work correctly if two are equal.
149 *h=enhance2(*h,a,b,c,d,e,f);
150 *s=enhance3(*s,*l,g,*h);
153 if(!ilSave(IL_PNG,argv[2]))mustard(OUTPIX_MUSTARD);
158 void mustard(int mustard)
163 if(q) printf("ENHANCED!\n");break;
164 case ARGUMENT_MUSTARD:
165 if(q) printf("bluenhanced inPix outPix a b c d e f [q]\n");break;
167 if(q) printf("inPIX mustard.\n");break;
169 if(q) printf("outPIX mustard.\n");break;
170 case ANIMATED_MUSTARD:
171 if(q) printf("Animation is mustard.\n");break;
173 if (q) printf("Ch*rpin* mustard mustaard!\n");
176 ilDeleteImages(1, &pix);