Server Help

Non-Subspace Related Coding - bmp2raw

Smong - Sun Sep 09, 2007 5:59 am
Post subject: bmp2raw
Since tcsoccerman decided not make this, and I kinda needed it I went ahead and made it.

It's primary purpose is generating raw textures for graphics libraries such as Open GL.

Currently it accepts 24-bit bmp's as from mspaint and can convert them to 8888, 4444, 5551 and 5650 formats. It can also optionally convert 1 color to represent full alpha transparency. One notable limitation is I didn't add support for the trailing zeroes found in bmp's that don't have a width divisible by 4, this isn't too much of a problem as textures have to be a power of 2 anyway.

I've included two sample images, they can be opened with Irfanview, but it has the byte order the wrong way round so colors are inversed (or something like that).

Here are the comments at the top of the source file:
Code: Show/Hide
* notes:
* - bitmap must be 24-bit format (default output of mspaint).
* - bitmap width must be a multiple of 4 (due to trailing zeroes).
* - for use as a texture bitmap dimensions must be a power of 2, but they
*    don't have to be the same, for example width 64 and height 128.
*
* fixme:
* - add support for bmps with widths not a multiple of 4 (trailing zeroes)
* - add support for paletted bmps (8-bit, etc) -> 8888
* - add support for generating palettes from 8888 bmps
*   (most likely use first n colors found instead of smart dithering)

tcsoccerman - Sun Sep 09, 2007 11:04 am
Post subject:
Sorry i couldn't make it, i had no idea what raw files were. I'll check it out.
Smong - Sun Sep 09, 2007 12:16 pm
Post subject:
That's ok. There's many different things with the .raw extension. Even Irfanview a generic image viewer opens my raw's differently from what I need.
tcsoccerman - Sun Sep 09, 2007 1:51 pm
Post subject:
ya i downloaded irfranview and it lookedwierd...
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group