diff options
| author | Alex Marshall <SquidMan72@gmail.com> | 2009-05-20 19:27:23 -0700 |
|---|---|---|
| committer | Alex Marshall <SquidMan72@gmail.com> | 2009-05-20 19:27:23 -0700 |
| commit | 4dae869236052f487d7626329a1cc68caeaeabe8 (patch) | |
| tree | 15f76effa8c00fe65dbdd4e400e837a44741e58b /zetsubou/tpl.c | |
| parent | ce5f828df9c91e32af9eeaca62fc96d38870985e (diff) | |
Lets try icefires RGBA8 code >_>
Diffstat (limited to 'zetsubou/tpl.c')
| -rw-r--r-- | zetsubou/tpl.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/zetsubou/tpl.c b/zetsubou/tpl.c index c6e4915..35a44fc 100644 --- a/zetsubou/tpl.c +++ b/zetsubou/tpl.c @@ -89,7 +89,7 @@ int TPL_ConvertBitMapToRGB565(u8* bitmapdata, u32 bitmapsize, u8** tplbuf, u32 w return outsz; } -int TPL_ConvertRGBA8ToBitMap(u8* tplbuf, u32 tplsize, u32 tplpoint, u8** bitmapdata, u32 width, u32 height) +/*int TPL_ConvertRGBA8ToBitMap(u8* tplbuf, u32 tplsize, u32 tplpoint, u8** bitmapdata, u32 width, u32 height) { u32 goodwidth = width; u32 goodheight = height; @@ -147,6 +147,45 @@ int TPL_ConvertRGBA8ToBitMap(u8* tplbuf, u32 tplsize, u32 tplpoint, u8** bitmapd } } return outsz; +}*/ +/* Let's try icefire's code. */ +int TPL_ConvertRGBA8ToBitMap(u8* tplbuf, u32 tplsize, u32 tplpoint, u8** bitmapdata, u32 width, u32 height) +{ + u32 goodwidth = width; + u32 goodheight = height; + u32 x, y; + u32 x1, y1; + *bitmapdata = (u8*)calloc(width * height, 4); + if(*bitmapdata == NULL) + return -1; + u32 outsz = width * height * 4; + u8 r, g, b, a; + int i, iv = 0; + int bmpslot = 0; + for(y1 = 0; y1 < height; y1 += 4) { + for(x1 = 0; x1 < width; x1 += 4) { + for(i = 0; i < 2; i++) { + for(y = y1; y < (y1 + 4); y++) { + for(x = x1; x < (x1 + 4); x++) { + u16 oldpixel = *(u16*)(tplbuf + (tplpoint + ((iv++) * 2))); + if((x >= width) || (y >= height)) + continue; + + if(i == 0) { + a = (oldpixel >> 8) & 0xFF; + r = (oldpixel >> 0) & 0xFF; + (*(u32**)bitmapdata)[x + (y * width)] |= ((r << 0) | (a << 24)); + } else { + g = (oldpixel >> 8) & 0xFF; + b = (oldpixel >> 0) & 0xFF; + (*(u32**)bitmapdata)[x + (y * width)] |= ((g << 8) | (b << 16)); + } + } + } + } + } + } + return outsz; } int TPL_ConvertBitMapToRGBA8(u8* bitmapdata, u32 bitmapsize, u8** tplbuf, u32 width, u32 height) |
