From dd39c97ab3efac228cc7d29a8665209c7f403f81 Mon Sep 17 00:00:00 2001 From: b Date: Sun, 30 Jun 2019 10:24:13 +0000 Subject: [PATCH] Initial state as of 30.06.2019 --- enhance.cpp | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 enhance.cpp diff --git a/enhance.cpp b/enhance.cpp new file mode 100644 index 0000000..bb6b615 --- /dev/null +++ b/enhance.cpp @@ -0,0 +1,218 @@ +// enhance.cpp +// The enhancement software - reveal hidden details +// 9.06.2019 +// +// Copyright (C) 2014 - 2019 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 . +// + +// 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 ARGUMENT_MUSTARD 4 + +#define ANIMATED_MUSTARD 6 +#define FAIL 900 +#define OK 0 + +#include +#include +#include +#include + +void mustard(int mustard); +ILubyte swap1(ILubyte x); +ILubyte swap2(ILubyte x); +ILubyte swap4(ILubyte x); +int main (int argc, const char *argv[]); + +ILuint pix; +ILboolean q=true; +ILboolean pixOpen=false; + + +ILubyte swap1(ILubyte x) +{ + ILubyte y=0; + + y |= x&0x01; + x >>= 1; + y <<= 1; + y |= x&0x01; + x >>= 1; + y <<= 1; + y |= x&0x01; + x >>= 1; + y <<= 1; + y |= x&0x01; + x >>= 1; + y <<= 1; + y |= x&0x01; + x >>= 1; + y <<= 1; + y |= x&0x01; + x >>= 1; + y <<= 1; + y |= x&0x01; + x >>= 1; + y <<= 1; + y |= x&0x01; + + return y; +} + +ILubyte swap2(ILubyte x) +{ + ILubyte y=0; + + y |= x&0x03; + x >>= 2; + y <<= 2; + y |= x&0x03; + x >>= 2; + y <<= 2; + y |= x&0x03; + x >>= 2; + y <<= 2; + y |= x&0x03; + + return y; +} + +ILubyte swap4(ILubyte x) +{ + ILubyte y=0; + + y |= x&0x0f; + x >>= 4; + y <<= 4; + y |= x&0x0f; + + return y; +} + +int main (int argc, const char *argv[]) +{ + ILuint inX, inY, inZ, inC; + ILubyte *newdata, *pal; + unsigned char indexed; + + if(argc<3) + mustard(ARGUMENT_MUSTARD); + if (argc>=4) + { + if (argv[3][0]=='q' || argv[3][0]=='Q') + q=false; + } + + if(q) printf("%s -> %s ",argv[1],argv[2]); + + ilInit(); + iluInit(); + if(!ilEnable(IL_ORIGIN_SET))mustard(FAIL); + if(!ilEnable(IL_FILE_OVERWRITE))mustard(FAIL); + ilClearColour(255,255,0,0); + ilGenImages(1, &pix); + pixOpen=true; + ilBindImage(pix); + if(!ilLoadImage(argv[1]))mustard(INPIX_MUSTARD); + indexed=(ilGetInteger(IL_IMAGE_FORMAT)==IL_COLOUR_INDEX)?1:0; + + if (indexed) + { + ilConvertPal(IL_PAL_RGB24); + inC=ilGetInteger(IL_PALETTE_NUM_COLS); + pal=ilGetPalette(); + + for(unsigned long k=0;k1)?IL_GIF:IL_PNG,argv[2]))mustard(OUTPIX_MUSTARD); + // no mustard + mustard(0); +} + +void mustard(int mustard) +{ + ILenum error; + while((error=ilGetError())!=IL_NO_ERROR) + printf("%d: %s\n",error,iluErrorString(error)); + switch(mustard) + { + case 0: + if(q) printf("ENHANCED!\n"); + break; + case ARGUMENT_MUSTARD: + if(q) + printf("enhance 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 ANIMATED_MUSTARD: + if(q) + printf("Animation is mustard.\n"); + break; + default: + if (q) + printf("Ch*rpin* mustard mustaard!\n"); + } + if(pixOpen) + ilDeleteImages(1, &pix); + exit(mustard); +} + -- 2.30.2