palpic2png.c: improve, make usable with ppic binary files
[rofl0r-openDOW.git] / utils / unscramble.c
blob615b95e82abbc5e7c628557a1e292de0f5e10799
1 #include "../palpic.h"
2 #include "leptonica/allheaders.h"
3 #include <string.h>
4 #pragma RcB2 LINK "-llept"
6 #include "../temp.c"
7 #define sprite temp
8 #define scramble_factor 2
10 int main() {
11 const struct palpic* f = & sprite .header;
12 PIX* o = pixCreate(f->width*scramble_factor, palpic_getspritecount(f) * palpic_getspriteheight(f)/scramble_factor, 32);
13 prgb* palette = palpic_getpalette(f);
14 prgb* bufptr = (prgb*) o->data;
15 size_t i;
16 for(i = 0; i < f->spritecount; i++) {
17 int x, y;
18 const uint8_t *source = palpic_getspritedata(f, i);
19 for(y = 0; y < palpic_getspriteheight(f); y++) {
20 for(x = 0; x < palpic_getspritewidth(f); x++) {
21 *bufptr++ = palette[*source++];
25 pixWritePng("test.png", o, 0.0);
26 return 0;