Skip to content

Releases: capnramses/apg

apg_bmp-v3.4.0 - RLE compression

31 May 21:46
78d715d
Compare
Choose a tag to compare

From the PR:

  • This update adds support for RLE (run-length encoding) 8 and 4-bit compression (as exported as a checkbox option by GIMP).
  • For projects using BMP as a simple/fast/editable image format it's quite handy to have a lossless compression option that can give 5-10x compression.
  • I developed this feature based on Microsoft's BMP RLE documentation.
  • Most historical samples of BMPs did not implement compression, which is why I didn't originally support this (hard to test), but I specifically wanted to support the same compression as exported by GIMP.
  • It turns out GIMP decides, based on the image, if it will use RLE4 or RLE8 compression. In my test project I ended up with a mix of standards, so I was able to support and test both.
  • Note that images with an alpha channel can not use this compression because they use one of two types of "BITMASK" in the compression field instead.
  • This PR does not attempt to support other compression formats (JPG, PNG, etc). I have not found an example of any other formats used.
  • I was not able to find reliable examples of images using the "delta position" escape code, so I do not support that here. Official documentation was fairly ambiguous as to how to treat that, and I don't implement anything I can't test.
  • Note that BMP RLE compression only worked on indexed (palette-based) 3-channel images.
  • Note that this PR does not include an option for writing RLE images. That could be easily done in an update.