+++ /dev/null
- // //It's 403fication Time!
- // // Take a picture and add a Megan to it!
- // //
- // // Requires Dev Image Library,
-// // //on Pentium III libdevil must be
- // // recompiled with --disable-ssl2 --disable-ssl3
- // //
- // // ~~bicyclesonthemoon
-
-#define INPIX_MUSTARD 1
-#define OUTPIX_MUSTARD 2
-#define MEGPIX_MUSTARD 3
-#define ARGUMENT_MUSTARD 4
-#define SEAISH_MUSTARD 5
-#define ANIMATED_MUSTARD 6
-#define FAIL 900
-#define OK 0
-
-#define MEGPIX "403.png"
-#define XM 553
-#define XA 262
-#define XB 226
-#define YM 395
-#define YA 131
-
-/*#define NPBPIX0 "npb0.png"
-#define X0 411
-#define X01 21
-#define X02 96
-#define Y0 404
-#define Y01 214
-#define Y02 68
-
-#define NPBPIX1 "npb1.png"
-#define X1 411
-#define X11 22
-#define X12 133
-#define Y1 404
-#define Y11 241
-#define Y12 94
-
-#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 loadmeg(const char *path);
-void m403(const char *path);
-int main (int argc, const char *argv[]);
-
-ILuint inPix, outPix, megPix;
-ILboolean q=true;
-ILboolean inH=false;
-ILboolean outH=false;
-ILboolean megH=false;
-ILuint inX, inY, outX, outY;
-ILubyte *newdata;
-
-int main (int argc, const char *argv[])
-{
- if(argc<3)
- mustard(ARGUMENT_MUSTARD);
- if (argc>=4)
- {
- if (argv[3][0]=='q' || argv[3][0]=='Q')
- q=false;
- }
-
- ilInit();
- if(!ilEnable(IL_ORIGIN_SET))mustard(FAIL);
- if(!ilEnable(IL_FILE_OVERWRITE))mustard(FAIL);
- ilClearColour(255,255,255,255);
- ilGenImages(1, &inPix);
- inH=true;
- ilBindImage(inPix);
- if(!ilLoadImage(argv[1]))mustard(INPIX_MUSTARD);
- if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(INPIX_MUSTARD);
- //if(!ilConvertPal(IL_PAL_RGBA32))mustard(FAIL);
-
- inX=ilGetInteger(IL_IMAGE_WIDTH);
- inY=ilGetInteger(IL_IMAGE_HEIGHT);
- if(ilGetInteger(IL_NUM_IMAGES)>1)
- mustard(ANIMATED_MUSTARD);
-
- m403(argv[2]);
- //ok
- mustard(0);
-}
-
-void loadmeg(const char *path)
-{
- ilGenImages(1, &megPix);
- megH=true;
- ilBindImage(megPix);
- if(!ilLoadImage(path))mustard(MEGPIX_MUSTARD);
- if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(MEGPIX_MUSTARD);
-}
-
-void m403(const char *path)
-{
- unsigned long i,j;
- outX=(inX+XB+6>XM)?(inX+XB+6):XM;
- outY=(inY+YA+6>YM)?(inY+YA+6):YM;
- ilGenImages(1, &outPix);
- outH=true;
- loadmeg(MEGPIX);
- newdata=ilGetData();
- ilBindImage(outPix);
- if(!ilTexImage(outX,outY,1,4,IL_RGBA,IL_UNSIGNED_BYTE,NULL))mustard(OUTPIX_MUSTARD);
- if(!ilClearImage())mustard(FAIL);
-
- ilSetPixels(0,0/**/,0,XM,YM,1,IL_RGBA,IL_UNSIGNED_BYTE,newdata);
- if(!ilOverlayImage(inPix,((inX/2<XA-XB)?(XA-inX/2):XB),outY-YA-inY,0))mustard(FAIL);
-
- newdata=ilGetData();
-
- for(i=0;i<outX;++i)
- {
- newdata[4*(i ) ]=0x00;
- newdata[4*(i )+1]=0x00;
- newdata[4*(i )+2]=0x00;
- newdata[4*(i )+3]=0xFF;
-
- newdata[4*(i+outX ) ]=0x00;
- newdata[4*(i+outX )+1]=0x00;
- newdata[4*(i+outX )+2]=0x00;
- newdata[4*(i+outX )+3]=0xFF;
-
- newdata[4*(i+outX*(outY-1)) ]=0x00;
- newdata[4*(i+outX*(outY-1))+1]=0x00;
- newdata[4*(i+outX*(outY-1))+2]=0x00;
- newdata[4*(i+outX*(outY-1))+3]=0xFF;
-
- newdata[4*(i+outX*(outY-2)) ]=0x00;
- newdata[4*(i+outX*(outY-2))+1]=0x00;
- newdata[4*(i+outX*(outY-2))+2]=0x00;
- newdata[4*(i+outX*(outY-2))+3]=0xFF;
- }
-
- for(j=2;j<outY-2;++j)
- {
- newdata[4*( outX*j) ]=0x00;
- newdata[4*( outX*j)+1]=0x00;
- newdata[4*( outX*j)+2]=0x00;
- newdata[4*( outX*j)+3]=0xFF;
-
- newdata[4*( 1+outX*j) ]=0x00;
- newdata[4*( 1+outX*j)+1]=0x00;
- newdata[4*( 1+outX*j)+2]=0x00;
- newdata[4*( 1+outX*j)+3]=0xFF;
-
- newdata[4*(outX-1+outX*j) ]=0x00;
- newdata[4*(outX-1+outX*j)+1]=0x00;
- newdata[4*(outX-1+outX*j)+2]=0x00;
- newdata[4*(outX-1+outX*j)+3]=0xFF;
-
-
- }
-
- newdata[4*(outX-1+outX*(outY-1)) ]=0xB6;
- newdata[4*(outX-1+outX*(outY-1))+1]=0xB6;
- newdata[4*(outX-1+outX*(outY-1))+2]=0xB6;
- newdata[4*(outX-1+outX*(outY-1))+3]=0xFF;
-
- newdata[4*( outX*(outY-1)) ]=0xB6;
- newdata[4*( outX*(outY-1))+1]=0xB6;
- newdata[4*( outX*(outY-1))+2]=0xB6;
- newdata[4*( outX*(outY-1))+3]=0xFF;
-
- newdata[4*(outX-1 ) ]=0xB6;
- newdata[4*(outX-1 )+1]=0xB6;
- newdata[4*(outX-1 )+2]=0xB6;
- newdata[4*(outX-1 )+3]=0xFF;
-
- newdata[ 0]=0xB6;
- newdata[ 1]=0xB6;
- newdata[ 2]=0xB6;
- newdata[ 3]=0xFF;
-
- if(!ilSave(IL_PNG,path))mustard(OUTPIX_MUSTARD);
-}
-
-/*void npbottify2(const char *path)
-{
-
-
- 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;
- }
- }
- }
-
-
- //
-
-
- 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;
-
-
-
-
-}*/
-
-void mustard(int mustard)
-{
- switch(mustard)
- {
- case 0:
- if(q) printf("403fied!\n");break;
- case ARGUMENT_MUSTARD:
- if(q) printf("npb inPix outPix [q]\n");break;
- case INPIX_MUSTARD:
- if(q) printf("inPIX mustard.\n");break;
- case OUTPIX_MUSTARD:
- if(q) printf("outPIX mustard.\n");break;
- case MEGPIX_MUSTARD:
- if(q) printf("megPIX mustard.\n");break;
- case SEAISH_MUSTARD:
- if(q) printf("Seaishness is mustard.\n");break;
- case ANIMATED_MUSTARD:
- if(q) printf("Animation is mustard.\n");break;
- default:
- if (q) printf("Ch*rpin* mustard mustaard!\n");
- }
- if(inH)
- ilDeleteImages(1, &inPix);
- if(outH)
- {
- ilDeleteImages(1, &outPix);
- //delete[] newdata;
- }
- if(megH)
- ilDeleteImages(1, &megPix);
- exit(mustard);
-}
-
return 0;
}
-
ILuint copy_1p_alpha (ILint64 src, ILint64 dst, ILint64 alpha, ILint64 max)
{
ILint64 v = (src * alpha + dst * (max - alpha)) / max;
return (ILuint)v;
}
+int palette_mix_index (ILuint n, struct PixelInfo *p, void *data)
+{
+ if (n < 3)
+ return EIO;
+
+ p[2].index = p[0].index * p[0].info.palette_num_cols + p[1].index;
+
+ return 0;
+}
+
+
// int action(
// ILuint n, struct PixelInfo *info, void *data
int copy_pixels (ILuint n, struct PixelInfo *p, void *data);
ILuint copy_1p_alpha (ILint64 src, ILint64 dst, ILint64 alpha, ILint64 max);
-int fill_color (ILuint n, struct PixelInfo *p, void *data);
\ No newline at end of file
+int fill_color (ILuint n, struct PixelInfo *p, void *data);
+int palette_mix_index (ILuint n, struct PixelInfo *p, void *data);
\ No newline at end of file
/*
diff.c
see the difference!
-29.11.2022
+30.11.2022
Copyright (C) 2022 Balthasar Szczepański
};
int difference (ILuint n, struct PixelInfo *p, void *data);
-int palette_mix (ILuint n, struct PixelInfo *p, void *data);
static inline ILuint diff_1ch (ILint64 x, ILint64 y, ILint64 A, ILint64 B, ILint64 F);
char DIFF_MISSING_ARGS[] = "Missing parameters.\ndiff inPixA inPixB outPix [RA GA BA [RB GB BB]]\n";
id,
xyf0, xyf0, xyf0,
0, 0, 0,
- &palette_mix,
+ &palette_mix_index,
flags,
&data
);
return 0;
}
-int palette_mix (ILuint n, struct PixelInfo *p, void *data)
-{
- if (n < 3)
- return EIO;
-
- p[2].index = p[0].index * p[0].info.palette_num_cols + p[1].index;
-
- return 0;
-}
-
static inline ILuint diff_1ch (ILint64 x, ILint64 y, ILint64 A, ILint64 B, ILint64 F)
{
ILint64 v;
#include "reveal.h"
#include "diff.h"
#include "npb.h"
+#include "pal_mix.h"
int main (int argc, char **argv)
{
f = &subtool_diff;
else if (strcmp(argv[1], "npb")==0)
f = &subtool_npb;
+ else if (strcmp(argv[1], "pal_mix")==0)
+ f = &subtool_pal_mix;
else
finish(EINVAL, "Unknown mode.\n");
+++ /dev/null
-// insert.c
-// The tool to hide two indexed images iside one
-// 25.06.2015
-//
-// Copyright (C) 2015 Balthasar Szczepański
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as
-// published by the Free Software Foundation, either version 3 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-// Requires Dev Image Library (libdevil) (http://openil.sourceforge.net/)
-// on Pentium III libdevil must be recompiled with
-// --disable-ssl2 --disable-ssl3
-// (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572954)
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "IL/il.h"
-
-int mustard(const char *t,int m,int e);
-int main(int argc, char *argv[]);
-
-ILuint inpix1, inpix2, outpix;
-unsigned char q =0;
-
-
-int main(int argc, char *argv[])
-{
-
- ILubyte *pal1, *pal2, *data1, *data2, *data;
- ILubyte pal[256*3];
- unsigned short i,j;
- unsigned long k;
- ILuint col1, col2, col, x1, x2, y1, y2;
-
- unsigned short p1, p2, p3;
-
- if (argc<4)
- return mustard("insert inpix1 inpix2 outpix [p1 p2]",0,1);
- if(argc>=5)
- p1=atoi(argv[4]);
- else
- p1=1;
- if(argc>=6)
- p2=atoi(argv[5]);
- else
- p2=0;
- if(argc>=7)
- q=1;
- p3=p1+p2;
-
- ilInit();
-
- ilEnable(IL_ORIGIN_SET);
- ilEnable(IL_FILE_OVERWRITE);
-
- ilGenImages(1,&inpix1);
- ilGenImages(1,&inpix2);
- ilGenImages(1,&outpix);
-
- ilBindImage(inpix1);
- if(!ilLoadImage(argv[1]))
- return mustard("inpix1 load fail.",1,1);
- if(ilGetInteger(IL_IMAGE_FORMAT)!=IL_COLOUR_INDEX)
- return mustard("inpix1 not indexed.",1,1);
- ilConvertPal(IL_PAL_RGB24);
- col1=ilGetInteger(IL_PALETTE_NUM_COLS);
- if(col1>16)
- return mustard("inpix1 too many colors.",1,1);
- x1=ilGetInteger(IL_IMAGE_WIDTH);
- y1=ilGetInteger(IL_IMAGE_HEIGHT);
- pal1=ilGetPalette();
- data1=ilGetData();
-
- ilBindImage(inpix2);
- if(!ilLoadImage(argv[2]))
- return mustard("inpix2 load fail.",1,1);
- if(ilGetInteger(IL_IMAGE_FORMAT)!=IL_COLOUR_INDEX)
- return mustard("inpix2 not indexed.",1,1);
- ilConvertPal(IL_PAL_RGB24);
- col2=ilGetInteger(IL_PALETTE_NUM_COLS);
- if(col2>16)
- return mustard("inpix2 too many colors.",1,1);
- if(col1!=col2)
- return mustard("different palette size.",1,1);
- x2=ilGetInteger(IL_IMAGE_WIDTH);
- if(x1!=x2)
- return mustard("different widths",1,1);
- y2=ilGetInteger(IL_IMAGE_HEIGHT);
- if(y1!=y2)
- return mustard("different heights",1,1);
- pal2=ilGetPalette();
- data2=ilGetData();
- col=col1*col2;
-
- for(i=0;i<col1;++i)
- {
- for(j=0;j<col2;++j)
- {
- pal[3*(i*col1+j) ]=(pal1[3*i ]*p1+pal2[3*j ]*p2)/p3;
- pal[3*(i*col1+j)+1]=(pal1[3*i+1]*p1+pal2[3*j+1]*p2)/p3;
- pal[3*(i*col1+j)+2]=(pal1[3*i+2]*p1+pal2[3*j+2]*p2)/p3;
- }
- }
-
- ilBindImage(outpix);
- if(!ilTexImage(x1,y1,1,1,IL_COLOUR_INDEX,IL_UNSIGNED_BYTE,NULL))
- return mustard ("outpix create fail.",1,1);
- ilRegisterPal(pal,col*3,IL_PAL_RGB24);
- data=ilGetData();
-
- for(k=0;k<x1*y1;++k)
- data[k]=data1[k]*col2+data2[k];
-
- if(!ilSave(IL_PNG,argv[3]))
- return mustard("outpix save fail",1,1);
-
- return mustard("Ok",1,0);
-
-
-}
-int mustard(const char *t, int m,int e)
-{
- if(!q)puts(t);
- switch (m)
- {
- case 1:
- ilDeleteImages(1,&inpix1);
- ilDeleteImages(1,&inpix2);
- ilDeleteImages(1,&outpix);
- case 0:
- default:
- return e;
- }
-}
-
# "makefile" is automatically generated from "makefile.1.mak"
-# 29.11.2022
+# 30.11.2022
#
# Copyright (C) 2022 Balthasar Szczepański
#
bluenh\
reveal\
diff\
-npb
+npb\
+pal_mix
C_STANDALONE=\
standalone-nofading.c\
standalone-bluenh.c\
standalone-reveal.c\
standalone-diff.c\
-standalone-npb.c
+standalone-npb.c\
+standalone-pal_mix.c
C_SUBTOOL=\
nofading.c\
bluenh.c\
reveal.c\
diff.c\
-npb.c
+npb.c\
+pal_mix.c
H_SUBTOOL=\
nofading.h\
bluenh.h\
reveal.h\
diff.h\
-npb.h
+npb.h\
+pal_mix.h
H_PNG=\
npb0.h\
# "makefile" is automatically generated from "makefile.1.mak"
-# 29.11.2022
+# 30.11.2022
#
# Copyright (C) 2022 Balthasar Szczepański
#
bluenh\
reveal\
diff\
-npb
+npb\
+pal_mix
C_STANDALONE=\
standalone-nofading.c\
standalone-bluenh.c\
standalone-reveal.c\
standalone-diff.c\
-standalone-npb.c
+standalone-npb.c\
+standalone-pal_mix.c
C_SUBTOOL=\
nofading.c\
bluenh.c\
reveal.c\
diff.c\
-npb.c
+npb.c\
+pal_mix.c
H_SUBTOOL=\
nofading.h\
bluenh.h\
reveal.h\
diff.h\
-npb.h
+npb.h\
+pal_mix.h
H_PNG=\
npb0.h\
+++ /dev/null
-// npb.cpp
-// NewpixbOTTification - The tool to add newpixbots to pictures
-// 16.01.2015
-//
-// Copyright (C) 2013 Balthasar Szczepański
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as
-// published by the Free Software Foundation, either version 3 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-// Requires Dev Image Library (libdevil) (http://openil.sourceforge.net/)
-// on Pentium III libdevil must be recompiled with
-// --disable-ssl2 --disable-ssl3
-// (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572954)
-
-#define INPIX_MUSTARD 1
-#define OUTPIX_MUSTARD 2
-#define NPBPIX_MUSTARD 3
-#define ARGUMENT_MUSTARD 4
-#define SEAISH_MUSTARD 5
-#define ANIMATED_MUSTARD 6
-#define FAIL 900
-#define OK 0
-
-#define NPBPIX2 "/eizm/mem/ong1/npb.png"
-#define X2 311
-#define X21 210
-#define Y2 475
-#define Y21 407
-
-#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 q=true;
-ILboolean inH=false;
-ILboolean outH=false;
-ILboolean npbH=false;
-ILuint inX, inY, outX, outY;
-ILubyte *newdata;
-
-int main (int argc, const char *argv[])
-{
- if(argc<3)
- mustard(ARGUMENT_MUSTARD);
- if (argc>=4)
- {
- if (argv[3][0]=='q' || argv[3][0]=='Q')
- q=false;
- }
-
- ilInit();
- if(!ilEnable(IL_ORIGIN_SET))mustard(FAIL);
- if(!ilEnable(IL_FILE_OVERWRITE))mustard(FAIL);
- ilClearColour(255,255,0,0);
- ilGenImages(1, &inPix);
- inH=true;
- ilBindImage(inPix);
- if(!ilLoadImage(argv[1]))mustard(INPIX_MUSTARD);
- if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(INPIX_MUSTARD);
- //if(!ilConvertPal(IL_PAL_RGBA32))mustard(FAIL);
-
- inX=ilGetInteger(IL_IMAGE_WIDTH);
- inY=ilGetInteger(IL_IMAGE_HEIGHT);
- if(ilGetInteger(IL_NUM_IMAGES)>1)
- mustard(ANIMATED_MUSTARD);
-
- // if(inX<=X02&&inY<=Y02)
- // npbottify0(argv[2]);
- // else if(inX<=X12&&inY<=Y12)
- // npbottify1(argv[2]);
- else
- npbottify2(argv[2]);
- //ok
- mustard(0);
-}
-
-void loadnpb(const char *path)
-{
- ilGenImages(1, &npbPix);
- npbH=true;
- ilBindImage(npbPix);
- if(!ilLoadImage(path))mustard(NPBPIX_MUSTARD);
- if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(NPBPIX_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;
-
- ilGenImages(1, &npbPix);
- npbH=true;
- ilBindImage(npbPix);
- if(!ilLoadImage(NPBPIX2))mustard(NPBPIX_MUSTARD);
- if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(NPBPIX_MUSTARD);
- ilBindImage(outPix);
- if(!ilOverlayImage(npbPix,outX-X2,outY-Y2,0))mustard(FAIL);
- //ilSetPixels(outX-X2,0,0,X2,Y2,1,IL_RGBA,IL_UNSIGNED_BYTE,newdata);
-
- if(!ilSave(IL_PNG,path))mustard(OUTPIX_MUSTARD);
-
-
-}
-
-void mustard(int mustard)
-{
- switch(mustard)
- {
- case 0:
- if(q) printf("NewpixbOTTified!\n");break;
- case ARGUMENT_MUSTARD:
- if(q) printf("npb inPix outPix [q]\n");break;
- case INPIX_MUSTARD:
- if(q) printf("inPIX mustard.\n");break;
- case OUTPIX_MUSTARD:
- if(q) printf("outPIX mustard.\n");break;
- case NPBPIX_MUSTARD:
- if(q) printf("npbPIX mustard.\n");break;
- case SEAISH_MUSTARD:
- if(q) printf("Seaishness is mustard.\n");break;
- case ANIMATED_MUSTARD:
- if(q) printf("Animation is mustard.\n");break;
- default:
- if (q) printf("Ch*rpin* mustard mustaard!\n");
- }
- if(inH)
- ilDeleteImages(1, &inPix);
- if(outH)
- {
- ilDeleteImages(1, &outPix);
- //delete[] newdata;
- }
- if(npbH)
- ilDeleteImages(1, &npbPix);
- exit(mustard);
-}
-
--- /dev/null
+/*
+pal_mix.c
+The tool to hide two indexed images iside one
+30.11.2022
+
+Copyright (C) 2015, 2022 Balthasar Szczepański
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+Requires Dev Image Library (libdevil) (http://openil.sourceforge.net/)
+on Pentium III libdevil must be recompiled with
+--disable-ssl2 --disable-ssl3
+(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572954)
+
+*/
+
+#include <stdint.h>
+#include <getopt.h>
+#include <errno.h>
+
+#include "core.h"
+#include "pal_mix.h"
+
+struct rel_data
+{
+ ILuint p0;
+ ILuint p1;
+ ILuint p;
+};
+
+int palette_mix_value (ILuint n, struct PixelInfo *p, void *data);
+ILuint mix_value_1ch (ILint64 x, ILint64 y, struct rel_data *rel);
+
+char PAL_MIX_MISSING_ARGS[] = "Missing parameters.\npal_mix inPix1 inpix2 outPix [p1 p2]\n";
+
+int subtool_pal_mix (int argc, char **argv, int argi, char **err)
+{
+ uint_fast16_t id[3] = {0, 1, 2};
+ ILint xyf0[3] = {0, 0, 0};
+ struct IL_full_info info[3];
+ FLAG_TYPE flags[3] = {
+ MUST_BE_INDEXED | NOT_WRITABLE | OK_PALETTE_ONLY,
+ MUST_BE_INDEXED | NOT_WRITABLE | OK_PALETTE_ONLY,
+ MUST_BE_INDEXED | NOT_READABLE | OK_PALETTE_ONLY
+ };
+ ILubyte new_pal[0x100 * 4];
+ struct rel_data data;
+ ILuint i;
+ int r;
+
+ if (argc < argi + 3)
+ {
+ *err = PAL_MIX_MISSING_ARGS;
+ return EINVAL;
+ }
+
+ if (argc >= argi + 5)
+ {
+ sscanf(argv[argi+3],"%u",&(data.p0));
+ sscanf(argv[argi+4],"%u",&(data.p1));
+ }
+ else
+ {
+ data.p0 = 1;
+ data.p1 = 0;
+ }
+ data.p = data.p0 + data.p1;
+
+ r = load_picture(0, argv[argi], &(info[0]), &(flags[0]));
+ if (r)
+ {
+ *err = LOAD_FAILED;
+ return r;
+ }
+
+ r = load_picture(1, argv[argi+1], &(info[1]), &(flags[1]));
+ if (r)
+ {
+ *err = LOAD_FAILED;
+ return r;
+ }
+
+ if ((info[0].image_height != info[1].image_height) || (info[0].image_width != info[1].image_width) || (info[0].num_images != info[1].num_images))
+ {
+ *err = SIZE_MISMATCH;
+ return EINVAL;
+ }
+
+ if ((info[0].palette_num_cols * info[1].palette_num_cols) > 0x100)
+ {
+ *err = BAD_PALETTE_SIZE;
+ return EINVAL;
+ }
+
+ if ((flags[0] & HAS_ALPHA) || (flags[1] & HAS_ALPHA))
+ {
+ flags[0] |= MUST_HAVE_ALPHA;
+ flags[1] |= MUST_HAVE_ALPHA;
+ flags[2] |= MUST_HAVE_ALPHA;
+ }
+ else
+ flags[2] |= CANNOT_HAVE_ALPHA;
+
+ r = convert_picture(0, &(info[0]), &(flags[0]));
+ if (r!=0)
+ {
+ *err = CONVERT_FAILED;
+ return EIO;
+ }
+
+ r = convert_picture(1, &(info[1]), &(flags[1]));
+ if (r!=0)
+ {
+ *err = CONVERT_FAILED;
+ return EIO;
+ }
+
+ r = build_picture_from_info(2, &(info[0]), &(info[2]), &(flags[2]));
+ if (r!=0)
+ {
+ *err = CREATE_FAILED;
+ return EIO;
+ }
+
+ for (i=0; i<=info[2].num_images; ++i)
+ {
+ set_palette (
+ 2,
+ new_pal,
+ info[0].palette_num_cols * info[1].palette_num_cols * info[0].palette_bpp,
+ info[0].palette_type,
+ i
+ );
+ }
+
+ r = perform_action_palette_mix(
+ id,
+ &palette_mix_value,
+ flags,
+ &data
+ );
+ if (r)
+ {
+ *err = CONVERT_FAILED;
+ return r;
+ }
+
+ flags[0] &= ~OK_PALETTE_ONLY;
+ flags[1] &= ~OK_PALETTE_ONLY;
+ flags[2] &= ~OK_PALETTE_ONLY;
+
+ r = perform_action(
+ 3,
+ id,
+ xyf0, xyf0, xyf0,
+ 0, 0, 0,
+ &palette_mix_index,
+ flags,
+ &data
+ );
+ if (r)
+ {
+ *err = CONVERT_FAILED;
+ return r;
+ }
+
+ r = save_picture(2, argv[argi+2], flags[2]);
+ if (r!=0)
+ {
+ *err = SAVE_FAILED;
+ return r;
+ }
+
+ return 0;
+}
+
+int palette_mix_value (ILuint n, struct PixelInfo *p, void *data)
+{
+ if (n < 3)
+ return EIO;
+
+ p[2].red = mix_value_1ch(p[0].red, p[1].red, data);
+ p[2].green = mix_value_1ch(p[0].green, p[1].green, data);
+ p[2].blue = mix_value_1ch(p[0].blue, p[1].blue, data);
+ if (p[2].flags & EFF_ALPHA)
+ p[2].alpha = mix_value_1ch(p[0].alpha, p[1].alpha, data);
+
+ return 0;
+}
+
+ILuint mix_value_1ch (ILint64 x, ILint64 y, struct rel_data *rel)
+{
+ ILint64 v = (x * rel->p0 + y * rel->p1) / rel->p;
+ return (ILuint) v;
+}
+
+/*
+#include <stdlib.h>
+#include <stdio.h>
+#include "IL/il.h"
+
+int mustard(const char *t,int m,int e);
+int main(int argc, char *argv[]);
+
+ILuint inpix1, inpix2, outpix;
+unsigned char q =0;
+
+
+int main(int argc, char *argv[])
+{
+
+ ILubyte *pal1, *pal2, *data1, *data2, *data;
+ ILubyte pal[256*3];
+ unsigned short i,j;
+ unsigned long k;
+ ILuint col1, col2, col, x1, x2, y1, y2;
+
+ unsigned short p1, p2, p3;
+
+ if (argc<4)
+ return mustard("insert inpix1 inpix2 outpix [p1 p2]",0,1);
+ if(argc>=5)
+ p1=atoi(argv[4]);
+ else
+ p1=1;
+ if(argc>=6)
+ p2=atoi(argv[5]);
+ else
+ p2=0;
+ if(argc>=7)
+ q=1;
+ p3=p1+p2;
+
+ ilInit();
+
+ ilEnable(IL_ORIGIN_SET);
+ ilEnable(IL_FILE_OVERWRITE);
+
+ ilGenImages(1,&inpix1);
+ ilGenImages(1,&inpix2);
+ ilGenImages(1,&outpix);
+
+ ilBindImage(inpix1);
+ if(!ilLoadImage(argv[1]))
+ return mustard("inpix1 load fail.",1,1);
+ if(ilGetInteger(IL_IMAGE_FORMAT)!=IL_COLOUR_INDEX)
+ return mustard("inpix1 not indexed.",1,1);
+ ilConvertPal(IL_PAL_RGB24);
+ col1=ilGetInteger(IL_PALETTE_NUM_COLS);
+ if(col1>16)
+ return mustard("inpix1 too many colors.",1,1);
+ x1=ilGetInteger(IL_IMAGE_WIDTH);
+ y1=ilGetInteger(IL_IMAGE_HEIGHT);
+ pal1=ilGetPalette();
+ data1=ilGetData();
+
+ ilBindImage(inpix2);
+ if(!ilLoadImage(argv[2]))
+ return mustard("inpix2 load fail.",1,1);
+ if(ilGetInteger(IL_IMAGE_FORMAT)!=IL_COLOUR_INDEX)
+ return mustard("inpix2 not indexed.",1,1);
+ ilConvertPal(IL_PAL_RGB24);
+ col2=ilGetInteger(IL_PALETTE_NUM_COLS);
+ if(col2>16)
+ return mustard("inpix2 too many colors.",1,1);
+ if(col1!=col2)
+ return mustard("different palette size.",1,1);
+ x2=ilGetInteger(IL_IMAGE_WIDTH);
+ if(x1!=x2)
+ return mustard("different widths",1,1);
+ y2=ilGetInteger(IL_IMAGE_HEIGHT);
+ if(y1!=y2)
+ return mustard("different heights",1,1);
+ pal2=ilGetPalette();
+ data2=ilGetData();
+ col=col1*col2;
+
+ for(i=0;i<col1;++i)
+ {
+ for(j=0;j<col2;++j)
+ {
+ pal[3*(i*col1+j) ]=(pal1[3*i ]*p1+pal2[3*j ]*p2)/p3;
+ pal[3*(i*col1+j)+1]=(pal1[3*i+1]*p1+pal2[3*j+1]*p2)/p3;
+ pal[3*(i*col1+j)+2]=(pal1[3*i+2]*p1+pal2[3*j+2]*p2)/p3;
+ }
+ }
+
+ ilBindImage(outpix);
+ if(!ilTexImage(x1,y1,1,1,IL_COLOUR_INDEX,IL_UNSIGNED_BYTE,NULL))
+ return mustard ("outpix create fail.",1,1);
+ ilRegisterPal(pal,col*3,IL_PAL_RGB24);
+ data=ilGetData();
+
+ for(k=0;k<x1*y1;++k)
+ data[k]=data1[k]*col2+data2[k];
+
+ if(!ilSave(IL_PNG,argv[3]))
+ return mustard("outpix save fail",1,1);
+
+ return mustard("Ok",1,0);
+
+
+}
+int mustard(const char *t, int m,int e)
+{
+ if(!q)puts(t);
+ switch (m)
+ {
+ case 1:
+ ilDeleteImages(1,&inpix1);
+ ilDeleteImages(1,&inpix2);
+ ilDeleteImages(1,&outpix);
+ case 0:
+ default:
+ return e;
+ }
+}
+
+*/
\ No newline at end of file
--- /dev/null
+/*
+pal_mix.h
+The tool to hide two indexed images iside one
+30.11.2022
+
+Copyright (C) 2022 Balthasar Szczepański
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+Requires Dev Image Library (libdevil) (http://openil.sourceforge.net/)
+on Pentium III libdevil must be recompiled with
+--disable-ssl2 --disable-ssl3
+(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572954)
+*/
+
+int subtool_pal_mix (int argc, char **argv, int argi, char **err);