test Convert_24b_bitmap_to_256()
This commit is contained in:
parent
d56915edc6
commit
d44f972c11
@ -808,7 +808,7 @@ OBJS = main.o init.o graph.o $(APIOBJ) misc.o special.o \
|
|||||||
pxtall2.o pxtall3.o pxwide2.o pxquad.o \
|
pxtall2.o pxtall3.o pxwide2.o pxquad.o \
|
||||||
windows.o brush.o realpath.o mountlist.o input.o hotkeys.o \
|
windows.o brush.o realpath.o mountlist.o input.o hotkeys.o \
|
||||||
transform.o pversion.o factory.o $(PLATFORMOBJ) \
|
transform.o pversion.o factory.o $(PLATFORMOBJ) \
|
||||||
loadsave.o loadsavefuncs.o \
|
loadsave.o loadsavefuncs.o \
|
||||||
fileformats.o miscfileformats.o libraw2crtc.o \
|
fileformats.o miscfileformats.o libraw2crtc.o \
|
||||||
brush_ops.o buttons_effects.o layers.o \
|
brush_ops.o buttons_effects.o layers.o \
|
||||||
oldies.o tiles.o colorred.o unicode.o gfx2surface.o \
|
oldies.o tiles.o colorred.o unicode.o gfx2surface.o \
|
||||||
@ -819,10 +819,11 @@ endif
|
|||||||
|
|
||||||
TESTSOBJS = $(patsubst %.c,%.o,$(wildcard tests/*.c)) \
|
TESTSOBJS = $(patsubst %.c,%.o,$(wildcard tests/*.c)) \
|
||||||
miscfileformats.o fileformats.o oldies.o libraw2crtc.o \
|
miscfileformats.o fileformats.o oldies.o libraw2crtc.o \
|
||||||
loadsavefuncs.o packbits.o \
|
loadsavefuncs.o packbits.o \
|
||||||
unicode.o \
|
op_c.o colorred.o \
|
||||||
|
unicode.o \
|
||||||
io.o realpath.o version.o pversion.o \
|
io.o realpath.o version.o pversion.o \
|
||||||
gfx2surface.o \
|
gfx2surface.o \
|
||||||
gfx2log.o gfx2mem.o
|
gfx2log.o gfx2mem.o
|
||||||
|
|
||||||
OBJ = $(addprefix $(OBJDIR)/,$(OBJS))
|
OBJ = $(addprefix $(OBJDIR)/,$(OBJS))
|
||||||
|
|||||||
@ -45,7 +45,9 @@
|
|||||||
// are sorted by length of the diagonal
|
// are sorted by length of the diagonal
|
||||||
//#define GRAFX2_QUANTIZE_CLUSTER_SORT_BY_VOLUME
|
//#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.
|
/// Convert RGB to HSL.
|
||||||
/// Both input and output are in the 0..255 range to use in the palette screen
|
/// 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);
|
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)
|
/// 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;
|
int size;
|
||||||
|
|
||||||
@ -1491,3 +1494,4 @@ int Convert_24b_bitmap_to_256_fast(T_Bitmap256 dest,T_Bitmap24B source,int width
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@ -4,3 +4,4 @@
|
|||||||
TEST(MOTO_MAP_pack)
|
TEST(MOTO_MAP_pack)
|
||||||
TEST(CPC_compare_colors)
|
TEST(CPC_compare_colors)
|
||||||
TEST(Packbits)
|
TEST(Packbits)
|
||||||
|
TEST(Convert_24b_bitmap_to_256)
|
||||||
|
|||||||
60
src/tests/testop_c.c
Normal file
60
src/tests/testop_c.c
Normal file
@ -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 <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
///@file testop_c.c
|
||||||
|
/// Unit tests.
|
||||||
|
///
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user