resource_dasm icon indicating copy to clipboard operation
resource_dasm copied to clipboard

Improvement : extracting as png instead of bmp

Open Ownezx opened this issue 1 year ago • 3 comments

Hi, I was recently extracting the files from slithereen and managed to use your library to extract all I wanted to extract.

I did realize as I was starting to compress my images into png that the lossless compression of the file format makes a massive difference for the color lookup table generated images. The file size goes from 1.9MB to 47kB.

Perhaps that format should be used for any image extracted to make the extract files lighter while not loosing any data.

Ownezx avatar Oct 27 '22 16:10 Ownezx

This is a good idea, but I'm hesitant to add more library dependencies (even for a library as well-tested and widely-distributed as libpng). One option that doesn't require a library dependency could be to add some sort of output filter option (similar to --external-preprocessor), so BMP images could be converted to other formats in a subprocess before being saved. I'll leave this open while considering the alternatives here.

fuzziqersoftware avatar Oct 27 '22 16:10 fuzziqersoftware

This is just some candy to make things nicer, not in any way necessary.

At the end of the day I encapsulated resource_dasm in a script that uses graphicsmagick to convert to png. The script can be found on the open-slithereen repo.

Ownezx avatar Oct 27 '22 19:10 Ownezx

lodepng is a two-file library without any dependencies for reading/writing PNG images (zlib license). It could be added to phosg?

There's also stb_image_write.h, which supports various image formats (public domain). Although it doesn't support writing gamma information, which is not required, but useful to make sure the image is displayed correctly (lodepng can write gamma information). Then again, adding code to write an sRGB and gAMA chunk shouldn't be that complicated.

Kristine1975 avatar Oct 28 '22 08:10 Kristine1975