void get_flags (struct IL_full_info *info, FLAG_TYPE *flags)
{
- *flags &= ~(HAS_ALPHA | IS_GRAY | IS_INDEXED | IS_MULTIPLE | IS_OVER_8BIT);
+ *flags &= ~(HAS_ALPHA | IS_GRAY | IS_INDEXED | IS_MULTIPLE | IS_OVER_8BIT | EFF_ALPHA | EFF_GRAY | EFF_INDEXED);
if (info->num_images > 0)
*flags |= IS_MULTIPLE;
switch (info->image_format)
{
case IL_COLOUR_INDEX:
- *flags |= IS_INDEXED;
+ *flags |= IS_INDEXED | EFF_INDEXED;
switch (info->palette_type)
{
case IL_PAL_BGR32:
break;
case IL_PAL_BGRA32:
case IL_PAL_RGBA32:
- *flags |= HAS_ALPHA;
+ *flags |= HAS_ALPHA | EFF_ALPHA;
break;
case IL_PAL_RGB24:
case IL_PAL_BGR24:
}
break;
case IL_LUMINANCE_ALPHA:
- *flags |= HAS_ALPHA;
+ *flags |= HAS_ALPHA | EFF_ALPHA;
case IL_LUMINANCE:
- *flags |= IS_GRAY;
+ *flags |= IS_GRAY | EFF_GRAY;
break;
case IL_RGBA:
case IL_BGRA:
- *flags |= HAS_ALPHA;
+ *flags |= HAS_ALPHA | EFF_ALPHA;
case IL_RGB:
case IL_BGR:
default:
if (r!=0)
break;
- p[i].flags &= ~(IS_GRAY|IS_INDEXED|IS_OVER_8BIT|IS_PALETTE_ONLY);
+ p[i].flags &= ~(HAS_ALPHA|IS_GRAY|IS_INDEXED|IS_OVER_8BIT|IS_PALETTE_ONLY|EFF_ALPHA|EFF_GRAY|EFF_INDEXED);
if (palette_only)
p[i].flags |= IS_PALETTE_ONLY;
switch (p[i].info.image_format)
{
case IL_COLOUR_INDEX:
- p[i].flags |= IS_INDEXED;
+ p[i].flags |= IS_INDEXED | EFF_INDEXED;
r = get_palette(p[i].id, &(p[i].palette), p[i].f_pict);
if (r!=0)
break;
p[i].flags |= IS_OVER_8BIT;
break;
case IL_PAL_BGRA32:
- p[i].flags |= HAS_ALPHA;
+ p[i].flags |= HAS_ALPHA | EFF_ALPHA;
p[i].alpha_offset = 3;
case IL_PAL_BGR24:
p[i].red_offset = 2;
p[i].blue_offset = 0;
break;
case IL_PAL_RGBA32:
- p[i].flags |= HAS_ALPHA;
+ p[i].flags |= HAS_ALPHA | EFF_ALPHA;
p[i].alpha_offset = 3;
case IL_PAL_RGB24:
default:
}
break;
case IL_LUMINANCE_ALPHA:
- p[i].flags |= HAS_ALPHA;
+ p[i].flags |= HAS_ALPHA | EFF_ALPHA;
p[i].alpha_offset = 1 * p[i].info.image_bpc;
case IL_LUMINANCE:
- p[i].flags |= IS_GRAY;
+ p[i].flags |= IS_GRAY | EFF_GRAY;
p[i].value_offset = 0 * p[i].info.image_bpc;
break;
case IL_BGRA:
- p[i].flags |= HAS_ALPHA;
+ p[i].flags |= HAS_ALPHA | EFF_ALPHA;
p[i].alpha_offset = 3 * p[i].info.image_bpc;
case IL_BGR:
p[i].red_offset = 2 * p[i].info.image_bpc;
p[i].blue_offset = 0 * p[i].info.image_bpc;
break;
case IL_RGBA:
- p[i].flags |= HAS_ALPHA;
+ p[i].flags |= HAS_ALPHA | EFF_ALPHA;
p[i].alpha_offset = 3 * p[i].info.image_bpc;
case IL_RGB:
default:
}
if (p[i].info.image_bpc > 1)
p[i].flags |= IS_OVER_8BIT;
+
+ if ((p[i].flags & IS_INDEXED) && (p[i].flags & CANNOT_BE_INDEXED))
+ p[i].flags &= ~EFF_INDEXED;
+ if ((p[i].flags & IS_GRAY) && (p[i].flags & CANNOT_BE_GRAY))
+ p[i].flags &= ~EFF_GRAY;
+ else if (!(p[i].flags & IS_GRAY) && (p[i].flags & MUST_BE_GRAY))
+ p[i].flags |= EFF_GRAY;
+ if ((!(p[i].flags & HAS_ALPHA)) && (p[i].flags & MUST_HAVE_ALPHA))
+ p[i].flags |= EFF_ALPHA;
+ else if ((p[i].flags & HAS_ALPHA) && (p[i].flags & CANNOT_HAVE_ALPHA))
+ p[i].flags &= ~EFF_ALPHA;
}
if (!skip_frame)
{
{
case IL_PAL_BGR32:
case IL_PAL_RGB32:
- p[i].flags |= IS_OVER_8BIT;
break;
case IL_PAL_BGRA32:
- p[i].flags |= HAS_ALPHA;
p[i].alpha_offset = 3;
case IL_PAL_BGR24:
p[i].red_offset = 2;
p[i].blue_offset = 0;
break;
case IL_PAL_RGBA32:
- p[i].flags |= HAS_ALPHA;
p[i].alpha_offset = 3;
case IL_PAL_RGB24:
default:
p[i].blue_offset = 2;
break;
}
+
+ if ((p[i].flags & IS_GRAY) && (p[i].flags & CANNOT_BE_GRAY))
+ p[i].flags &= ~EFF_GRAY;
+ else if (!(p[i].flags & IS_GRAY) && (p[i].flags & MUST_BE_GRAY))
+ p[i].flags |= EFF_GRAY;
+ if ((!(p[i].flags & HAS_ALPHA)) && (p[i].flags & MUST_HAVE_ALPHA))
+ p[i].flags |= EFF_ALPHA;
+ else if ((p[i].flags & HAS_ALPHA) && (p[i].flags & CANNOT_HAVE_ALPHA))
+ p[i].flags &= ~EFF_ALPHA;
}
if (!skip_frame)
{
return (ILubyte)(x >> (8 * (bytes-1)));
}
+int copy_pixels (ILuint n, struct PixelInfo *p, void *data)
+{
+ ILuint max = *((ILuint *)data);
+
+ if (n < 2)
+ return EINVAL;
+
+ if (p[0].flags & EFF_INDEXED)
+ {
+ if (!(p[1].flags & EFF_INDEXED))
+ return EINVAL;
+ p[1].index = p[0].index;
+ }
+ else if (p[0].flags & EFF_ALPHA)
+ {
+ if (p[0].flags & EFF_GRAY)
+ {
+ if (!(p[1].flags & EFF_GRAY))
+ return EINVAL;
+ p[1].value = copy_1p_alpha(p[0].value, p[1].value, p[0].alpha, max);
+ }
+ else
+ {
+ if (p[1].flags & EFF_GRAY)
+ return EINVAL;
+ p[1].red = copy_1p_alpha(p[0].red, p[1].red, p[0].alpha, max);
+ p[1].green = copy_1p_alpha(p[0].green, p[1].green, p[0].alpha, max);
+ p[1].blue = copy_1p_alpha(p[0].blue, p[1].blue, p[0].alpha, max);
+ }
+ if (p[1].flags & EFF_ALPHA)
+ p[1].alpha = copy_1p_alpha(max, p[1].alpha, p[0].alpha, max);
+ }
+ else
+ {
+ if (p[0].flags & EFF_GRAY)
+ {
+ if (!(p[1].flags & EFF_GRAY))
+ return EINVAL;
+ p[1].value = p[0].value
+ }
+ else
+ {
+ if (p[1].flags & EFF_GRAY)
+ return EINVAL;
+ p[1].red = p[0].red;
+ p[1].green = p[0].green;
+ p[1].blue = p[0].blue;
+ }
+ if (p[1].flags & EFF_ALPHA)
+ p[1].alpha = max;
+ }
+
+ return 0;
+}
+
+int fill_color (ILuint n, struct PixelInfo *p, void *data)
+{
+ struct ColorInfo *d = data;
+
+ if (p->flags & EFF_INDEXED)
+ {
+ p->index = d->index;
+ }
+ else
+ {
+ if (p->flags & EFF_ALPHA)
+ p->alpha = d->alpha;
+ if (p->flags & EFF_GRAY)
+ p->value = d->value;
+ else
+ {
+ p->red = d->red;
+ p->green = d->green;
+ p->blue = d->blue;
+ }
+ }
+
+ return 0;
+}
+
+
+ILuint copy_1p_alpha (ILint64 src, ILint64 dst, ILint64 alpha, iILint64 max)
+{
+ ILint64 v = (src * alpha + dst * (max - alpha)) / max;
+ return (ILuint)v;
+}
+
+
// int action(
// ILuint n, struct PixelInfo *info, void *data
// )
#define FLAG_TYPE uint_fast32_t
-#define MUST_HAVE_ALPHA 0x00001
-#define CANNOT_HAVE_ALPHA 0x00002
-#define MUST_BE_GRAY 0x00004
-#define CANNOT_BE_GRAY 0x00008
-#define MUST_BE_INDEXED 0x00010
-#define CANNOT_BE_INDEXED 0x00020
+#define MUST_HAVE_ALPHA 0x000001
+#define CANNOT_HAVE_ALPHA 0x000002
+#define MUST_BE_GRAY 0x000004
+#define CANNOT_BE_GRAY 0x000008
+#define MUST_BE_INDEXED 0x000010
+#define CANNOT_BE_INDEXED 0x000020
-#define OK_PALETTE_ONLY 0x00040
-#define CAN_BE_MULTIPLE 0x00080
-#define CAN_BE_OVER_8BIT 0x00100
+#define OK_PALETTE_ONLY 0x000040
+#define CAN_BE_MULTIPLE 0x000080
+#define CAN_BE_OVER_8BIT 0x000100
-#define IN_WINDOW 0x00200
+#define IN_WINDOW 0x000200
-#define HAS_ALPHA 0x00400
-#define IS_GRAY 0x00800
-#define IS_INDEXED 0x01000
-#define IS_MULTIPLE 0x02000
-#define IS_OVER_8BIT 0x04000
-#define IS_PALETTE_ONLY 0x08000
+#define HAS_ALPHA 0x000400
+#define IS_GRAY 0x000800
+#define IS_INDEXED 0x001000
+#define IS_MULTIPLE 0x002000
+#define IS_OVER_8BIT 0x004000
+#define IS_PALETTE_ONLY 0x008000
-#define NOT_WRITABLE 0x10000
-#define NOT_READABLE 0x20000
+#define NOT_WRITABLE 0x010000
+#define NOT_READABLE 0x020000
+
+#define EFF_ALPHA 0x040000
+#define EFF_GRAY 0x080000
+#define EFF_INDEXED 0x100000
extern char NO_STR[];
extern char INIT_FAILED[];
struct IL_full_info info;
};
-typedef int (ACTION_F)(ILuint n, struct PixelInfo *info, void *data);
+struct ColorInfo
+{
+ ILuint red;
+ ILuint green;
+ ILuint blue;
+ ILuint value;
+ ILuint alpha;
+ ILuint index;
+}
+typedef int (ACTION_F)(ILuint n, struct PixelInfo *info, void *data);
typedef int (SUBTOOL_F)(int argc, char **argv, int argi, char **err);
-
-
-
void finish (int const returnvalue, char const * const returntext);
void *data
);
-//ACTION_F action;
\ No newline at end of file
+
+
+int copy_pixels (ILuint n, struct PixelInfo *p, void *data);
+ILuint copy_1p_alpha (ILint64 src, ILint64 dst, ILint64 alpha, iILint64 max);
+int fill_color (ILuint n, struct PixelInfo *p, void *data);
\ No newline at end of file
p[2].red = diff_1ch(p[0].red, p[1].red, d->r_a, d->r_b, d->max);
p[2].green = diff_1ch(p[0].green, p[1].green, d->g_a, d->g_b, d->max);
p[2].blue = diff_1ch(p[0].blue, p[1].blue, d->b_a, d->b_b, d->max);
- if (p[2].flags & HAS_ALPHA)
+ if (p[2].flags & EFF_ALPHA)
p[2].alpha = (p[0].alpha + p[1].alpha) / 2; /* no better idea */
return 0;
#include "bluenh.h"
#include "reveal.h"
#include "diff.h"
+#include "npb.h"
int main (int argc, char **argv)
{
--- /dev/null
+/*
+f2h.c
+make file into h
+29.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/>.
+
+*/
+
+#include <stdio.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <errno.h>
+
+char DEFAULT_NAME[] = "data";
+FILE *infile, *outfile;
+uint_fast8_t in_open = 0;
+uint_fast8_t out_open = 0;
+
+int cleanup(int r)
+{
+ if (out_open)
+ fclose(outfile);
+ if (in_open)
+ fclose(infile);
+ return r;
+}
+
+int main (int argc, char **argv)
+{
+ char *name;
+ uint_fast8_t i;
+ uint8_t x;
+ uint_fast64_t size=0;
+
+ if (argc >= 2)
+ name = argv[1];
+ else
+ name = DEFAULT_NAME;
+ if (argc >= 3)
+ {
+ infile = fopen(argv[2], "rb");
+ if (infile==NULL)
+ return cleanup(EIO);
+ in_open = 1;
+ }
+ else
+ infile = stdin;
+ if (argc >= 4)
+ {
+ outfile = fopen(argv[3], "wt");
+ if (outfile==NULL)
+ return cleanup(EIO);
+ out_open = 1;
+ }
+ else
+ outfile = stdout;
+
+ fprintf(
+ outfile,
+ "/* %s is autogenerated%s%s. */\n",
+ out_open ? argv[3] : "File",
+ in_open ? " from " : "",
+ in_open ? argv[2] : ""
+ );
+ fputs ("#include <stdint.h>\n", outfile);
+ fprintf(
+ outfile,
+ "const uint8_t %s[] = {",
+ name
+ );
+ for (i=0; fread(&x, 1, 1, infile)!=0;i=(i+1)&7)
+ {
+ fprintf(
+ outfile,
+ "%s0x%02" PRIX8 ",",
+ (i==0) ? "\n\t" : " ",
+ x
+ );
+ ++size
+ }
+ fputs ("\n};\n", outfile);
+ fprintf(
+ outfile,
+ "#define %s_size %" PRIu64 "\n",
+ name,
+ size
+ );
+
+ return cleanup(0);
+}
info\
bluenh\
reveal\
-diff
+diff\
+npb
C_STANDALONE=\
standalone-nofading.c\
standalone-info.c\
standalone-bluenh.c\
standalone-reveal.c\
-standalone-diff.c
+standalone-diff.c\
+standalone-npb.c
C_SUBTOOL=\
nofading.c\
info.c\
bluenh.c\
reveal.c\
-diff.c
+diff.c\
+npb.c
H_SUBTOOL=\
nofading.h\
info.h\
bluenh.h\
reveal.h\
-diff.h
+diff.h\
+npb.h
+
+H_PNG=\
+npb0.h\
+npb1.h\
+npb2.h\
+npb_ong1.h\
+npb_403.h
+
+# keep these 2 lists in the same order!:
+GENERATE_FROM=
+
+TO_GENERATE=
+
#all: 403 npb npbd npb-ong1 npbd-ong1 bluenh bluenhd insert extract seediff insertframe mremapt-1 compare nofading nofadingd
$(CONFIGURE_CMD) < makefile.1.mak > makefile
-enhance: enhance.c core.h core.c $(H_SUBTOOL) $(C_SUBTOOL)
+enhance: enhance.c core.h core.c $(H_SUBTOOL) $(C_SUBTOOL) $(H_PNG)
$(CC) $(CF) -o enhance enhance.c core.c $(C_SUBTOOL) $(L_IL)
-$(STANDALONE): %: standalone-%.c %.c %.h core.c core.h
+$(STANDALONE): %: standalone-%.c %.c %.h core.c core.h $(H_PNG)
$(CC) $(CF) -o $@ standalone-$*.c $*.c core.c $(L_IL)
$(C_STANDALONE): standalone-%.c: settings-standalone.txt standalone.c
$(CONFIGURE) subtool=$* settings-standalone.txt --in standalone.c --out $@
+$(TO_GENERATE): $(GENERATE_FROM) $(CONFIGFILE)
+ $(CONFIGURE_CMD) --in $(GENERATE_FROM) --out $(TO_GENERATE)
+
+$(H_PNG): %.h: %.png f2h
+ ./f2h $* $*.png $@
+
+f2h: f2h.c
+ $(CC) $(CF) -o f2h f2h.c
+
#test: test.c core.h core.c
# $(CC) $(CF) -o test test.c core.c $(LF)
clean:
- $(RM) -f enhance $(C_STANDALONE) $(STANDALONE)
+ $(RM) -f enhance $(C_STANDALONE) $(STANDALONE) $(TO_GENERATE) f2h $(H_PNG)
PHONY: all clean
info\
bluenh\
reveal\
-diff
+diff\
+npb
C_STANDALONE=\
standalone-nofading.c\
standalone-info.c\
standalone-bluenh.c\
standalone-reveal.c\
-standalone-diff.c
+standalone-diff.c\
+standalone-npb.c
C_SUBTOOL=\
nofading.c\
info.c\
bluenh.c\
reveal.c\
-diff.c
+diff.c\
+npb.c
H_SUBTOOL=\
nofading.h\
info.h\
bluenh.h\
reveal.h\
-diff.h
+diff.h\
+npb.h
+
+H_PNG=\
+npb0.h\
+npb1.h\
+npb2.h\
+npb_ong1.h\
+npb_403.h
+
+# keep these 2 lists in the same order!:
+GENERATE_FROM=
+
+TO_GENERATE=
+
#all: 403 npb npbd npb-ong1 npbd-ong1 bluenh bluenhd insert extract seediff insertframe mremapt-1 compare nofading nofadingd
$(CONFIGURE_CMD) < makefile.1.mak > makefile
-enhance: enhance.c core.h core.c $(H_SUBTOOL) $(C_SUBTOOL)
+enhance: enhance.c core.h core.c $(H_SUBTOOL) $(C_SUBTOOL) $(H_PNG)
$(CC) $(CF) -o enhance enhance.c core.c $(C_SUBTOOL) $(L_IL)
-$(STANDALONE): %: standalone-%.c %.c %.h core.c core.h
+$(STANDALONE): %: standalone-%.c %.c %.h core.c core.h $(H_PNG)
$(CC) $(CF) -o $@ standalone-$*.c $*.c core.c $(L_IL)
$(C_STANDALONE): standalone-%.c: settings-standalone.txt standalone.c
$(CONFIGURE) subtool=$* settings-standalone.txt --in standalone.c --out $@
+$(TO_GENERATE): $(GENERATE_FROM) $(CONFIGFILE)
+ $(CONFIGURE_CMD) --in $(GENERATE_FROM) --out $(TO_GENERATE)
+
+$(H_PNG): %.h: %.png f2h
+ ./f2h $* $*.png $@
+
+f2h: f2h.c
+ $(CC) $(CF) -o f2h f2h.c
+
#test: test.c core.h core.c
# $(CC) $(CF) -o test test.c core.c $(LF)
clean:
- $(RM) -f enhance $(C_STANDALONE) $(STANDALONE)
+ $(RM) -f enhance $(C_STANDALONE) $(STANDALONE) $(TO_GENERATE) f2h $(H_PNG)
PHONY: all clean
/*
nofading.c
The tool to remove fading from an image
-15.11.2022
+29.11.2022
Copyright (C) 2015, 2022 Balthasar Szczepański
d = data;
- if (p->flags & IS_GRAY)
+ if (p->flags & EFF_GRAY)
{
UPDATE_RANGE(p->value, d->green_low, d->green_high);
}
UPDATE_RANGE(p->green, d->green_low, d->green_high);
UPDATE_RANGE(p->blue, d->green_low, d->green_high);
}
- if ((p->flags & HAS_ALPHA) && (d->enhance_alpha))
+ if ((p->flags & EFF_ALPHA) && (d->enhance_alpha))
{
UPDATE_RANGE(p->alpha, d->alpha_low, d->alpha_high);
}
d = data;
- if (p->flags & IS_GRAY)
+ if (p->flags & EFF_GRAY)
p->value = enhance_fading_1ch(p->value, d->green_low, d->green_high, d->max);
else if (d->individual_channels)
{
p->green = enhance_fading_1ch(p->green, d->green_low, d->green_high, d->max);
p->blue = enhance_fading_1ch(p->blue , d->green_low, d->green_high, d->max);
}
- if ((p->flags & HAS_ALPHA) && (d->enhance_alpha))
+ if ((p->flags & EFF_ALPHA) && (d->enhance_alpha))
p->alpha = enhance_fading_1ch(p->alpha, d->alpha_low, d->alpha_high, d->max);
return 0;
- // //It's NewpixbOTTification Time!
- // // Take a picture and add a newpixbot to it!
- // //
- // // Requires Dev Image Library,
-// // //on Pentium III libdevil must be
- // // recompiled with --disable-ssl2 --disable-ssl3
- // //
- // // ~~bicyclesonthemoon
+/*
+npb.c
+Take a picture and add a newpixbot to it!
+29.11.2022
+
+Copyright (C) 2013 - 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 "core.h"
+#include "npb.h"
+
+#include "npb0.h"
+#include "npb1.h"
+#include "npb2.h"
+#include "npb_ong1.h"
+#include "npb_403.h"
+
+#define NPB0_L 21
+#define NPB0_R 116
+#define NPB0_T 122
+#define NPB0_B 189
+
+#define NPB1_L 22
+#define NPB1_R 154
+#define NPB1_T 69
+#define NPB1_B 162
+
+
+char NPB_MISSING_ARGS[] = "Missing parameters.\nnpb [-o -4 -r -b -c] inPix outPix\n";
+
+int subtool_npb (int argc, char **argv, int argi, char **err)
+{
+ uint_fast8_t ong1 = 0;
+ uint_fast8_t t403 = 0;
+ uint_fast8_t corners = 0;
+ uint_fast8_t fullsize = 0;
+ uint_fast8_t fill_white = 0;
+ uint_fast8_t expand_left = 0;
+ uint_fast8_t expand_right = 0;
+ uint_fast8_t expand_up = 0;
+ uint_fast8_t expand_down = 0;
+ uint_fast8_t border_outside = 0;
+
+ ILuint cut_border = 0;
+ ILuint new_border = 2;
+ ILuint max = 0xFF; //upscale_value(0xFF, info[0].image_bpc); // bpc=1
+ ILuint effective_width, effective_height;
+ const uint8_t *npb_pix;
+ uint_fast32_t npb_size;
+ ILuint x_l, x_r, y_t, y_b;
+
+ struct ColorInfo color;
+ struct IL_full_info info[3];
+ FLAG_TYPE flags [3] = {
+ CANNOT_BE_GRAY | CANNOT_BE_INDEXED | NOT_WRITABLE,
+ CANNOT_BE_GRAY | CANNOT_BE_INDEXED | NOT_WRITABLE | MUST_HAVE_ALPHA,
+ CANNOT_BE_GRAY | CANNOT_BE_INDEXED | NOT_READABLE | MUST_HAVE_ALPHA,
+ }
+ ILuint x0[3];
+ ILuint y0[3];
+
+ struct option long_options[] = {
+ {"ong1", no_argument, NULL, 'o'},
+ {"403", no_argument, NULL, '4'},
+ {"remove-border", required_argument, NULL, 'r'},
+ {"new-border", required_argument, NULL, 'b'},
+ {"corners", no_argument, NULL, 'c'},
+ {"help", no_argument, NULL, 'h'},
+ {0, 0, 0, 0}
+ };
+ char short_options[] = "o4r:b:ch";
+
+ int opt;
+ int r;
+
+ optind = argi;
+ while ((opt = getopt_long(argc, argv, short_options, long_options, NULL)) != -1)
+ {
+ switch (opt)
+ {
+ case 'o':
+ ong1 = 1;
+ break;
+ case '4':
+ t403 = 1;
+ break;
+ case 'r':
+ sscanf(optarg, "%lu, &cut_border);
+ break;
+ case 'b':
+ sscanf(optarg, "%lu, &new_border);
+ fullsize = 1;
+ break;
+ case 'c':
+ corners = 1;
+ break;
+ case 'h':
+ /* help */
+ break;
+ }
+ }
+
+ if (argc < optind + 2)
+ {
+ *err = NPB_MISSING_ARGS;
+ return EINVAL;
+ }
+
+ r = reserve_pictures(1);
+ if (r)
+ {
+ *err = CREATE_FAILED;
+ return r;
+ }
+
+ r = load_picture(0, argv[optind], &(info[0]), &(flags[0]);
+ if (r)
+ {
+ *err = LOAD_FAILED;
+ return r;
+ }
+
+ effective_width = (info[0].image_width > (2*cut_border)) ? (info[0].image_width - (2*cut_border)) : 0;
+ effective_height = (info[0].image_height > (2*cut_border)) ? (info[0].image_height - (2*cut_border)) : 0;
+
+ if (t403)
+ {
+ npb_pix = npb_403;
+ npb_size = npb_403_size;
+ }
+ else if (ong1)
+ {
+ npb_pix = npb_ong1;
+ npb_size = npb_ong1_size;
+ }
+ else if ((effective_width <= NPB0_X_MAX) && (effective_height <= NPB0_Y_MAX) && (!fullsize))
+ {
+ npb_pix = npb0;
+ npb_size = npb0_size;
+ fill_white = 1;
+ new_border = 0;
+ }
+ else if ((effective_width <= NPB1_X_MAX) && (effective_height <= NPB1_Y_MAX) && (!fullsize))
+ {
+ npb_pix = npb1;
+ npb_size = npb1_size;
+ fill_white = 1;
+ new_border = 0;
+ }
+ else
+ {
+ npb_pix = npb2;
+ npb_size = npb2_size;
+ }
+
+
+}
#define INPIX_MUSTARD 1
#define OUTPIX_MUSTARD 2
ilDeleteImages(1, &npbPix);
exit(mustard);
}
-
+ */
--- /dev/null
+/*
+npb.h
+Take a picture and add a newpixbot to it!
+29.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_npb (int argc, char **argv, int argi, char **err);
/*
reveal.c
reveal hidden details
-15.11.2022
+29.11.2022
Copyright (C) 2014 - 2019, 2022 Balthasar Szczepański
int reveal (ILuint n, struct PixelInfo *p, void *data)
{
- if (p->flags & IS_GRAY)
+ if (p->flags & EFF_GRAY)
p->value = reveal_swap2(p->value);
else
{