Monochrome images

BlitzMax Forums/BlitzMax Programming/Monochrome images

Czar Flavius(Posted 2010) [#1]
I have some monochrome images (actually they are just black and white only!) by which I mean a lot of them. Is there a special way to load them so that I can conserve video memory?


ImaginaryHuman(Posted 2010) [#2]
Well, what file format are they?

If you want to get minimal memory use then you need to load it so that you store 8 pixels in a byte... ie 1 bit identifies black or white for each pixel.


Czar Flavius(Posted 2010) [#3]
They can be any file format, but let's say png. They are going to be shaddows.


Jesse(Posted 2010) [#4]
I believe BlitzMax load minimum 8 bit with pixmap. I can almost remember mark saying that "Timages" loading were always going to be converted to PF_RBGA8888: 32 bit or something like that.


Czar Flavius(Posted 2010) [#5]
In laymans terms, can I load a monochrome image in any way to reduce video memory usage?


Jesse(Posted 2010) [#6]
maybe Brucy's freeImage module can handle that.


jkrankie(Posted 2010) [#7]
I would think that your best chance of doing this is with FreeImage

Cheers
Charlie


ima747(Posted 2010) [#8]
Since they are going to be shadows, they will eventually end up in texture memory to be drawn. To end up there they will end up in RGBA8888 32bit. So assuming you're planning on displaying them without doing anything fancy, or you're not just loading them to just sorta have... I believe the answer is no. You may be able to load with FreeImage in lower bit format, but to draw them they will have to then be converted to pixmaps, and the rest is history.

You could create your own image object format with drawing routines that raise their bitdepth on the fly or something, but realistically I think you need to either find a way to dynamically load what you need, or accept the memory footprint. Both of those would be a lot easier IMO, and dynamic loading would also be a much more useful tool than a monochrome custom image format if you're going to invest some time.


Gabriel(Posted 2010) [#9]
What about this PF_I8 (8 Bit Intensity) pixel format? Does that tie in with an equivalent surface format in DirectX/OpenGL? I know DirectX had the D3DFMT_P8 format which is 8 bit palletized, but I don't know if it's practical to use it or not. I had a feeling it was removed between DX8 and DX9 but I can't find much info now to check it.


ImaginaryHuman(Posted 2010) [#10]
I'm not sure what Max does with loading paletted png's but if it's a monochrome png I expect that means a 1-bitplane palette indexed image. *IF* blitz even loads it, it will convert it to 24-bit truecolor which means every pixel which could potentially be stored as 1 bit gets turned into 3 BYTES.... 24 times as much data.

If you want to keep it in the smallest amount of memory possible, and if you insist on using PNG, then you'll have to load it as a PNG then convert it to 8 pixels-per-byte, ie 1 pixel per bit, monochrome.

You could try Intensity8 format but that means 1 byte per pixel. Alpha8 is also the same. It's a matter of how soon/often you want to DRAW the image, because if you want optimum storage you're not going to be able to keep it in a drawable format. If you want it to be drawable, either you must store/convert it to a 8-bit or 24-bit pixmap, or you must store it as a 24-bit image.