Packing images

BlitzMax Forums/BlitzMax Programming/Packing images

Robert Cummings(Posted 2009) [#1]
Yo,

I'd like to make my own image packer since it'll export other useful info in a data file with it. Is there a simple command to copy pngs to a bitmap and keep the alpha channel info and then save it out?

Simple is best!


xlsior(Posted 2009) [#2]
Bitmap (.bmp) doesn't support alpha IIRC


Pharmhaus(Posted 2009) [#3]
you can save png's with a compression of 0 which is nearly the same like bmp. then you can use your own compression method.


ImaginaryHuman(Posted 2009) [#4]
PNG is a whole file format, are you saying that you want to extract only the parts pertaining to compressed data and throw away the rest?


Retimer(Posted 2009) [#5]
Yeah, why not just pack the additional info you want to carry before the file in the package, then tack on the png ontop of that data.

I have my own packer to re-illistrate my own compressed archive (so it's a bit more protected and customized than zip/rar files), and what I do is write the real file size, compressed size, file version, and additional data for the file, then write the compressed version of the file after that data.

For your case though, since png's are already compressed, something like this perhaps? :: (maybe not so dumbed down, but you get the idea)

package.writeint(<length of info>)
package.writestring(<info>)
package.writeint(<size of png>)
package.writefile(<actual png>)


In the end you can still load the png right from the block of data inside the package containing the file, rather then having to save it then reload it, or any other weird stuff.


Robert Cummings(Posted 2009) [#6]
I need to basically create a surface, draw bitmaps with it and have that surface in memory still retain alpha information, then save the whole lot as a .png with alpha for loading in the game. I don't know if this is possible in Blitzmax (does it save out alpha? do surfaces or windows retain alpha?)

I am also on a mac so dlls are not really possible.