diff --git a/src/Makefile b/src/Makefile
index dd2d6177..d4890fb1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -808,7 +808,7 @@ OBJS = main.o init.o graph.o $(APIOBJ) misc.o special.o \
pxtall2.o pxtall3.o pxwide2.o pxquad.o \
windows.o brush.o realpath.o mountlist.o input.o hotkeys.o \
transform.o pversion.o factory.o $(PLATFORMOBJ) \
- loadsave.o loadsavefuncs.o \
+ loadsave.o loadsavefuncs.o \
fileformats.o miscfileformats.o libraw2crtc.o \
brush_ops.o buttons_effects.o layers.o \
oldies.o tiles.o colorred.o unicode.o gfx2surface.o \
@@ -819,10 +819,11 @@ endif
TESTSOBJS = $(patsubst %.c,%.o,$(wildcard tests/*.c)) \
miscfileformats.o fileformats.o oldies.o libraw2crtc.o \
- loadsavefuncs.o packbits.o \
- unicode.o \
+ loadsavefuncs.o packbits.o \
+ op_c.o colorred.o \
+ unicode.o \
io.o realpath.o version.o pversion.o \
- gfx2surface.o \
+ gfx2surface.o \
gfx2log.o gfx2mem.o
OBJ = $(addprefix $(OBJDIR)/,$(OBJS))
diff --git a/src/op_c.c b/src/op_c.c
index 9e0ee8fa..e9366638 100644
--- a/src/op_c.c
+++ b/src/op_c.c
@@ -45,7 +45,9 @@
// are sorted by length of the diagonal
//#define GRAFX2_QUANTIZE_CLUSTER_SORT_BY_VOLUME
-int Convert_24b_bitmap_to_256_fast(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette);
+#if defined(__GP2X__) || defined(__gp2x__) || defined(__WIZ__) || defined(__CAANOO__)
+static int Convert_24b_bitmap_to_256_fast(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette);
+#endif
/// Convert RGB to HSL.
/// Both input and output are in the 0..255 range to use in the palette screen
@@ -1471,8 +1473,9 @@ int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int
extern void Set_palette_fake_24b(T_Palette palette);
+#if defined(__GP2X__) || defined(__gp2x__) || defined(__WIZ__) || defined(__CAANOO__)
/// Really small, fast and dirty convertor(just for handhelds)
-int Convert_24b_bitmap_to_256_fast(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette)
+static int Convert_24b_bitmap_to_256_fast(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette)
{
int size;
@@ -1491,3 +1494,4 @@ int Convert_24b_bitmap_to_256_fast(T_Bitmap256 dest,T_Bitmap24B source,int width
}
return 0;
}
+#endif
diff --git a/src/tests/testlist.h b/src/tests/testlist.h
index 3278f1ef..0f6842b9 100644
--- a/src/tests/testlist.h
+++ b/src/tests/testlist.h
@@ -4,3 +4,4 @@
TEST(MOTO_MAP_pack)
TEST(CPC_compare_colors)
TEST(Packbits)
+TEST(Convert_24b_bitmap_to_256)
diff --git a/src/tests/testop_c.c b/src/tests/testop_c.c
new file mode 100644
index 00000000..eb61bc81
--- /dev/null
+++ b/src/tests/testop_c.c
@@ -0,0 +1,60 @@
+/* vim:expandtab:ts=2 sw=2:
+*/
+/* Grafx2 - The Ultimate 256-color bitmap paint program
+
+ Copyright 2018-2019 Thomas Bernard
+ Copyright 2011 Pawel Góralski
+ Copyright 2009 Petter Lindquist
+ Copyright 2008 Yves Rizoud
+ Copyright 2008 Franck Charlet
+ Copyright 2007-2011 Adrien Destugues
+ Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
+
+ Grafx2 is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; version 2
+ of the License.
+
+ Grafx2 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Grafx2; if not, see
+*/
+///@file testop_c.c
+/// Unit tests.
+///
+#include
+#include
+#include "../op_c.h"
+#include "../gfx2log.h"
+
+int Test_Convert_24b_bitmap_to_256(void)
+{
+ T_Palette palette;
+ byte dest[256];
+ T_Components source[256];
+ int i;
+
+ // first try if a 256 colors picture is converted OK
+ for (i = 0; i < 256; i++)
+ {
+ source[i].R = i;
+ source[i].G = i;
+ source[i].B = i;
+ }
+ if (Convert_24b_bitmap_to_256(dest, source, 16, 16, palette) != 0)
+ {
+ return 0;
+ }
+ GFX2_LogHexDump(GFX2_DEBUG, "", dest, 0, 256);
+ for (i = 0; i < 256; i++)
+ {
+ if (memcmp(&source[i], &palette[dest[i]], sizeof(T_Components)) != 0)
+ return 0;
+ }
+ // TODO: test a real reduction
+ return 1;
+}