3 #include "leptonica/allheaders.h"
5 #pragma RcB2 LINK "-llept"
11 const prgb color_tab
[] = {
13 PRGB(0xff, 0xdd, 0x55), //yellow
14 PRGB(0xbb, 0xbb, 0xbb), // light gray
15 PRGB(0x11, 0x33, 0x33), // dark gray
16 PRGB(0x22, 0x22, 0x22), // dummy2
17 PRGB(0x33, 0x33, 0x33), // dummy3
18 PRGB(0xbb, 0x55, 0x11), // orange
19 PRGB(0x66, 0x66, 0x66), // dummy6
20 PRGB(0xff, 0xff, 0xdd), // white
21 PRGB(0x11, 0x11, 0x11), // dummy1
22 PRGB(0xbb, 0x77, 0x55), // light orange
23 PRGB(0x77, 0x55, 0x11), // brown,
24 PRGB(0x44, 0x44, 0x44), // dummy4
25 PRGB(0x55, 0x55, 0x55), // dummy5
26 PRGB(0x77, 0x77, 0x77), // dummy7
27 PRGB(0xbb, 0x99, 0x55), // light brown
29 const struct palpic
* f
= &sprite
.header
;
30 PIX
* o
= pixCreate(f
->width
, f
->height
/ BITPLANES
, 32);
31 int w
= palpic_getspritewidth(f
);
32 int h
= palpic_getspriteheight(f
);
35 prgb
* bufptr
= (prgb
*) o
->data
;
36 for(i
= 0; i
+(BITPLANES
-1) < f
->spritecount
; i
+=BITPLANES
) {
37 memset(plane
, 0, sizeof plane
);
41 for(j
= 0; j
< BITPLANES
; j
++) {
42 const uint8_t *source
= palpic_getspritedata(f
, i
+ j
);
43 for(y
= 0; y
< h
; y
++) {
44 for(x
= 0; x
< w
; x
++) {
45 if(*source
) plane
[y
][x
] |= 1 << j
;
50 for(j
= 0; j
< sizeof plane
; j
++) {
51 *bufptr
++ = color_tab
[((uint8_t*)plane
)[j
]];
54 pixWritePng("test.png", o
, 0.0);