2

On my research for RLE decompression of Bitmaps i have stumbled across a possible "delta"-combination, which basically skips a certain amount of "dont care" pixels. I just cannot wrap my head around how this should work. How am i supposed to just skip the these pixels, they have to be filled with SOME value, and how do i pass this information of these pixels being "dont care" pixels. Im losing my mind..!

Here are the main two sources and a excerpt of the interesting part:

The last marker is the run offset marker, also called a delta or vector code. This marker is four bytes in size, with the first two bytes being the values 00 and 02, and the last two values specifying a pixel address using unsigned X and Y values as an offset from the current bitmap cursor position. The X value is the number of pixels across the scan line, and the Y value is the number of rows forward in the bitmap.

This run offset marker indicates the location in the bitmap where the next decoded run of pixels should be written. For example, a run offset marker value of 00 02 05 03 would indicate that the offset of the bitmap cursor should move five pixels down the scan line, three rows forward, and write out the next run. The cursor then continues writing decoded data from its new position moving forward.

Run offset markers are used when a bitmap may contain a large amount of "don't care" pixels. For example, if the BMP file holds a bitmap used as a mask (such as those used with icons and pointers), many of the pixels in the rectangular bitmap may not be used. Rather than store these unused pixels in the BMP file, only the significant pixels are stored, and the delta markers are used as "jumps" to skip over the parts of the bitmap not actually used in the mask.

Thank you very much!

  • 1
    "they have to be filled with SOME value" .. the memory already has some value, be it zero, or some garbage. So you can leave it as is and move your write pointer to the new location. Or explicitly write a zero or whatever else you desire. It doesn't really matter. – Dan Mašek Jul 08 '20 at 23:51
  • 1
    1/3: Thank you! Sorry for my late answer, i have read your comment, i was just not super satisfied with the argumentation, so i did more research. In case you (or someone else) want to know - i figured out these don't care pixels are probably always zero. The Bitmap Format holds a colortable for Bitmaps with colordepth less then 16bpp. This colortable is most of the time sorted, with the most important / most used color at the index 0. The bits assigned to store the pixelinformation (its color) is then not holding a useful colorcode itself, but holds a index reference to this colortable. – Halid Zehic Jul 13 '20 at 13:19
  • 1
    2/3: This means, by default all pixels (with colordepth of 1-, 4- or 8bpp) which are 0, are holding the most used color in the picture. These markers are then used to efficiently skip all Pixels with value 0, as its probably occuring in larger sequences. – Halid Zehic Jul 13 '20 at 13:21
  • 1
    3/3: For newer Bitmap Versions with colordepth >= 16bpp, these 'dont care' pixels could also be part of a mask layer, where (i think) it should not matter what actual value they hold, as this part gets merged with one or more other mask layers. But i think the conventional value for the 'Background' value is still zero. For a 1bpp Bitmap, the value 0 is documented as the 'background value' and the value 1 is set to be the 'foreground value'. I have not researched deeper into mask layers, but i think that would make sense. – Halid Zehic Jul 13 '20 at 13:30

0 Answers0