1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2014 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
27 #include <core/GP_Pixmap.h>
28 #include <core/GP_GetPutPixel.h>
29 #include <loaders/GP_PCX.h>
36 GP_PixelType pixel_type
;
40 static int test_load_PCX(struct testcase
*test
)
46 img
= GP_LoadPCX(test
->path
, NULL
);
51 tst_msg("Not Implemented");
54 tst_msg("Got %s", strerror(errno
));
59 if (img
->w
!= test
->w
|| img
->h
!= test
->h
) {
60 tst_msg("Wrong size have %ux%u expected %ux%u",
61 img
->w
, img
->h
, test
->w
, test
->h
);
66 if (img
->pixel_type
!= test
->pixel_type
) {
67 tst_msg("Wrong pixel type have %s expected %s",
68 GP_PixelTypeName(img
->pixel_type
),
69 GP_PixelTypeName(test
->pixel_type
));
74 unsigned int x
, y
, fail
= 0;
76 for (x
= 0; x
< img
->w
; x
++) {
77 for (y
= 0; y
< img
->w
; y
++) {
78 GP_Pixel p
= GP_GetPixel(img
, x
, y
);
80 if (p
!= test
->pixel
) {
82 tst_msg("First failed at %u,%u %x %x",
83 x
, y
, p
, test
->pixel
);
90 tst_msg("Pixmap pixels are correct");
100 static struct testcase v3_0_1bpp_10x10_white
= {
101 .path
= "ver3_0_palette_1bpp_10x10_white.pcx",
104 .pixel_type
= GP_PIXEL_G1
,
108 static struct testcase v3_0_2bpp_10x10_white
= {
109 .path
= "ver3_0_palette_2bpp_10x10_white.pcx",
112 .pixel_type
= GP_PIXEL_RGB888
,
116 static struct testcase v3_0_4bpp_10x10_white
= {
117 .path
= "ver3_0_palette_4bpp_10x10_white.pcx",
120 .pixel_type
= GP_PIXEL_RGB888
,
124 static struct testcase v2_8_4bpp_10x10_white
= {
125 .path
= "ver2_8_palette_4bpp_10x10_white.pcx",
128 .pixel_type
= GP_PIXEL_RGB888
,
132 static struct testcase v3_0_8bpp_10x10_white
= {
133 .path
= "ver3_0_palette_8bpp_10x10_white.pcx",
136 .pixel_type
= GP_PIXEL_RGB888
,
140 static struct testcase v3_0_24bpp_10x10_white
= {
141 .path
= "ver3_0_palette_24bpp_10x10_white.pcx",
144 .pixel_type
= GP_PIXEL_RGB888
,
148 const struct tst_suite tst_suite
= {
151 {.name
= "PCX Load ver3.0 1bpp 10x10 white",
152 .tst_fn
= test_load_PCX
,
153 .res_path
= "data/pcx/valid/ver3_0_palette_1bpp_10x10_white.pcx",
154 .data
= &v3_0_1bpp_10x10_white
,
155 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
157 {.name
= "PCX Load ver3.0 2bpp 10x10 white",
158 .tst_fn
= test_load_PCX
,
159 .res_path
= "data/pcx/valid/ver3_0_palette_2bpp_10x10_white.pcx",
160 .data
= &v3_0_2bpp_10x10_white
,
161 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
163 {.name
= "PCX Load ver3.0 4bpp 10x10 white",
164 .tst_fn
= test_load_PCX
,
165 .res_path
= "data/pcx/valid/ver3_0_palette_4bpp_10x10_white.pcx",
166 .data
= &v3_0_4bpp_10x10_white
,
167 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
169 {.name
= "PCX Load ver2.8 4bpp 10x10 white",
170 .tst_fn
= test_load_PCX
,
171 .res_path
= "data/pcx/valid/ver2_8_palette_4bpp_10x10_white.pcx",
172 .data
= &v2_8_4bpp_10x10_white
,
173 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
175 {.name
= "PCX Load ver3.0 8bpp 10x10 white",
176 .tst_fn
= test_load_PCX
,
177 .res_path
= "data/pcx/valid/ver3_0_palette_8bpp_10x10_white.pcx",
178 .data
= &v3_0_8bpp_10x10_white
,
179 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
181 {.name
= "PCX Load ver3.0 24bpp 10x10 white",
182 .tst_fn
= test_load_PCX
,
183 .res_path
= "data/pcx/valid/ver3_0_palette_24bpp_10x10_white.pcx",
184 .data
= &v3_0_24bpp_10x10_white
,
185 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},