6 Copyright (C) 2014 - 2019, 2022 Balthasar SzczepaĆski
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Affero General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Affero General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 Requires Dev Image Library (libdevil) (http://openil.sourceforge.net/)
23 on Pentium III libdevil must be recompiled with
24 --disable-ssl2 --disable-ssl3
25 (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572954)
35 char REVEAL_MISSING_ARGS[] = "Missing parameters.\nreveal inPix outPix\n";
37 int reveal (ILuint n, struct PixelInfo *p, void *data);
38 static inline ILubyte reveal_swap1(ILubyte x);
39 static inline ILubyte reveal_swap2(ILubyte x);
40 static inline ILubyte reveal_swap4(ILubyte x);
43 int subtool_reveal (int argc, char **argv, int argi, char **err)
45 struct IL_full_info info;
46 FLAG_TYPE flags = CAN_BE_MULTIPLE | OK_PALETTE_ONLY;
51 *err = REVEAL_MISSING_ARGS;
55 r = reserve_pictures(1);
62 r = load_picture(0, argv[argi], &info, &flags);
69 r = perform_action_1picture (
78 *err = CONVERT_FAILED;
82 r = save_picture (0, argv[argi+1], flags);
92 int reveal (ILuint n, struct PixelInfo *p, void *data)
94 if (p->flags & EFF_GRAY)
95 p->value = reveal_swap2(p->value);
98 p->red = reveal_swap4(p->red);
99 p->green = reveal_swap2(p->green);
100 p->blue = reveal_swap1(p->blue);
106 static inline ILubyte reveal_swap1(ILubyte x)
136 static inline ILubyte reveal_swap2(ILubyte x)
154 static inline ILubyte reveal_swap4(ILubyte x)