ILubyte v;
struct bluenh_data data;
struct IL_full_info info;
- FLAG_TYPE flags = CAN_BE_MULTIPLE | CAN_BE_OVER_8BIT;
+ FLAG_TYPE flags = CAN_BE_MULTIPLE | CAN_BE_OVER_8BIT | OK_PALETTE_ONLY;
int r;
if (argc < argi + 8)
max
);
}
-
-/*
-#define INPIX_MUSTARD 1
-#define OUTPIX_MUSTARD 2
-
-#define ARGUMENT_MUSTARD 4
-
-#define ANIMATED_MUSTARD 6
-#define FAIL 900
-#define OK 0
-
-#define CR newdata[4*(i+inX*j)+0]
-#define CG newdata[4*(i+inX*j)+1]
-#define CB newdata[4*(i+inX*j)+2]
-
-#define A ((long)(a))
-#define B ((long)(b))
-#define C ((long)(c))
-#define D ((long)(d))
-#define E ((long)(e))
-#define F ((long)(f))
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <IL/il.h>
-
-void mustard(int mustard);
-ILubyte enhance(ILubyte x, long r, long s, long t);
-ILubyte enhance2(ILubyte x, ILubyte a, ILubyte b, ILubyte c, ILubyte d, ILubyte e, ILubyte f);
-ILubyte enhance3(ILubyte x, ILubyte a, ILubyte b, ILubyte c);
-int main (int argc, const char *argv[]);
-
-ILuint pix;
-ILboolean q=true;
-ILboolean pixOpen=false;
-
-
-ILubyte enhance(ILubyte x, long r, long s, long t)
-{
- long y=(r*x+t)/s;
- return (ILubyte)((y>255)?255:((y<0)?0:y));
-}
-
-ILubyte enhance2(ILubyte x, ILubyte a, ILubyte b, ILubyte c, ILubyte d, ILubyte e, ILubyte f)
-{
- 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))));
-}
-
-ILubyte enhance3(ILubyte x, ILubyte a, ILubyte b, ILubyte c)
-{
- return enhance(x,C-A,B-A,(B-C)*A);
-}
-
-int main (int argc, const char *argv[])
-{
- ILubyte a,b,c,d,e,f,g;
- ILubyte *h, *s, *l;
- ILuint inX, inY;
- ILubyte *newdata;
-
- if(argc<9)
- mustard(ARGUMENT_MUSTARD);
- if (argc>=10)
- {
- if (argv[9][0]=='q' || argv[9][0]=='Q')
- q=false;
- }
-
- sscanf(argv[3],"%hhu",&a);
- sscanf(argv[4],"%hhu",&b);
- sscanf(argv[5],"%hhu",&c);
- sscanf(argv[6],"%hhu",&d);
- sscanf(argv[7],"%hhu",&e);
- sscanf(argv[8],"%hhu",&f);
-
- ilInit();
- 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);
- if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(INPIX_MUSTARD);
-
- inX=ilGetInteger(IL_IMAGE_WIDTH);
- inY=ilGetInteger(IL_IMAGE_HEIGHT);
- if(ilGetInteger(IL_NUM_IMAGES)>1)
- mustard(ANIMATED_MUSTARD);
-
- newdata=ilGetData();
- for(unsigned long i=0;i<inX;++i)
- {
- for(unsigned long j=0;j<inY;++j)
- {
- if(CR==CG&&CG==CB)
- continue;
- //it'll stilll work correctly if two are equal.
- if(CR>CG)
- {
- if(CG>CB)
- {
- h=&(CR);
- s=&(CG);
- l=&(CB);
- }
- else if(CB>CR)
- {
- h=&(CB);
- s=&(CR);
- l=&(CG);
- }
- else
- {
- h=&(CR);
- s=&(CB);
- l=&(CG);
- }
- }
- else
- {
- if(CR>CB)
- {
- h=&(CG);
- s=&(CR);
- l=&(CB);
- }
- else if(CB>CG)
- {
- h=&(CB);
- s=&(CG);
- l=&(CR);
- }
- else
- {
- h=&(CG);
- s=&(CB);
- l=&(CR);
- }
- }
- g=*h;
- *h=enhance2(*h,a,b,c,d,e,f);
- *s=enhance3(*s,*l,g,*h);
- }
- }
- if(!ilSave(IL_PNG,argv[2]))mustard(OUTPIX_MUSTARD);
- // no mustard
- mustard(0);
-}
-
-void mustard(int mustard)
-{
- switch(mustard)
- {
- case 0:
- if(q) printf("ENHANCED!\n");break;
- case ARGUMENT_MUSTARD:
- if(q) printf("bluenhanced inPix outPix a b c d e f [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);
-}
-*/
// #include <stdio.h>
// #include <errno.h>
-#include "IL/il.h"
+#include <IL/il.h>
#define FLAG_TYPE uint_fast32_t
#include "info.h"
#include "nofading.h"
#include "bluenh.h"
+#include "reveal.h"
int main (int argc, char **argv)
{
f = &subtool_info;
else if (strcmp(argv[1], "bluenh")==0)
f = &subtool_bluenh;
+ else if (strcmp(argv[1], "reveal")==0)
+ f = &subtool_reveal;
else
finish(EINVAL, "Unknown mode.\n");
if (r!=0)
finish(r, error_text);
-
finish(0, "");
}
\ No newline at end of file
STANDALONE=\
nofading\
info\
-bluenh
+bluenh\
+reveal
C_STANDALONE=\
standalone-nofading.c\
standalone-info.c\
-standalone-bluenh.c
+standalone-bluenh.c\
+standalone-reveal.c
C_SUBTOOL=\
nofading.c\
info.c\
-bluenh.c
+bluenh.c\
+reveal.c
H_SUBTOOL=\
nofading.h\
info.h\
-bluenh.h
+bluenh.h\
+reveal.h
#all: 403 npb npbd npb-ong1 npbd-ong1 bluenh bluenhd insert extract seediff insertframe mremapt-1 compare nofading nofadingd
STANDALONE=\
nofading\
info\
-bluenh
+bluenh\
+reveal
C_STANDALONE=\
standalone-nofading.c\
standalone-info.c\
-standalone-bluenh.c
+standalone-bluenh.c\
+standalone-reveal.c
C_SUBTOOL=\
nofading.c\
info.c\
-bluenh.c
+bluenh.c\
+reveal.c
H_SUBTOOL=\
nofading.h\
info.h\
-bluenh.h
+bluenh.h\
+reveal.h
#all: 403 npb npbd npb-ong1 npbd-ong1 bluenh bluenhd insert extract seediff insertframe mremapt-1 compare nofading nofadingd
-// 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 <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)
+/*
+reveal.c
+reveal hidden details
+13.11.2022
+Copyright (C) 2014 - 2019, 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 <stdio.h>
+#include <errno.h>
+
+#include "reveal.h"
+#include "core.h"
+
+char REVEAL_MISSING_ARGS[] = "Missing parameters.\nreveal inPix outPix\n";
+
+int reveal (ILuint n, struct PixelInfo *p, void *data);
+static inline ILubyte reveal_swap1(ILubyte x);
+static inline ILubyte reveal_swap2(ILubyte x);
+static inline ILubyte reveal_swap4(ILubyte x);
+
+
+int subtool_reveal (int argc, char **argv, int argi, char **err)
+{
+ struct IL_full_info info;
+ FLAG_TYPE flags = CAN_BE_MULTIPLE | OK_PALETTE_ONLY;
+ int r;
+
+ if (argc < argi + 2)
+ {
+ *err = REVEAL_MISSING_ARGS;
+ return EINVAL;
+ }
+
+ r = create_pictures(1);
+ if (r)
+ {
+ *err = CREATE_FAILED;
+ return r;
+ }
+
+ r = load_picture(0, argv[argi], &info, &flags);
+ if (r)
+ {
+ *err = LOAD_FAILED;
+ return r;
+ }
+
+ r = action_1picture (
+ 0,
+ 0, 0, 0, 0, 0, 0,
+ &reveal,
+ flags,
+ NULL
+ );
+ if (r)
+ {
+ *err = CONVERT_FAILED;
+ return r;
+ }
+
+ r = save_picture (0, argv[argi+1], flags);
+ if (r)
+ {
+ *err = SAVE_FAILED;
+ return r;
+ }
+
+ return 0;
+}
+
+int reveal (ILuint n, struct PixelInfo *p, void *data)
+{
+ if (p->flags & IS_GRAY)
+ p->value = reveal_swap2(p->value);
+ else
+ {
+ p->red = reveal_swap4(p->red);
+ p->green = reveal_swap2(p->green);
+ p->blue = reveal_swap1(p->blue);
+ }
+
+ return 0;
+}
+
+static inline ILubyte reveal_swap1(ILubyte x)
+{
+ ILubyte y = 0x00;
+
+ 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;
+}
+
+static inline ILubyte reveal_swap2(ILubyte x)
+{
+ ILubyte y = 0x00;
+
+ 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;
+}
+
+static inline ILubyte reveal_swap4(ILubyte x)
+{
+ ILubyte y = 0x00;
+
+ y |= x&0x0f;
+ x >>= 4;
+ y <<= 4;
+ y |= x&0x0f;
+
+ return y;
+}
+
+/*
#define INPIX_MUSTARD 1
#define OUTPIX_MUSTARD 2
ilDeleteImages(1, &pix);
exit(mustard);
}
-
+*/
--- /dev/null
+/*
+reveal.h
+reveal hidden details
+13.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_reveal (int argc, char **argv, int argi, char **err);