Einzelnen Beitrag anzeigen

Kas Ob.
Online

Registriert seit: 3. Sep 2023
213 Beiträge
 
#2

AW: weniger Scanline aufrufe ... Graustufenbild

  Alt 11. Feb 2024, 09:11
Hi,

First you need to define 16bit and 8bit bit per pixel format, because there is many !

8bit and 16bit are so old when different systems had different color space, example : 8bit pixel either colored or gray, in colored case is it 332 or 233 for RGB or BGR ...
Same goes for 16bit, is there Alpha, in case of alpha then mostly it is 5551 or 1555 if not then 555 or 565, is it BGR(A) or (A)RGB...

Searching for good resource is semi-useless, again unless you have one specific format to follow,.. the best i could find is this :
https://learn.microsoft.com/en-gb/wi...ith-16-bit-rgb
and if we talk Windows Bitmap then this might give a little insight too https://en.wikipedia.org/wiki/BMP_file_format

notice
1) in the first link from Microsoft, the pixel decode is done by masking and bit shifting, again there is only two mentioned here RGB 555 and RGB 565, not mention for Alpha.
2) For converting these color, 5bit or 6bit to 8bit per color you need to multiply by 8 or by 4, this operation is bit shifting by 3 or 2, making a single color of 5bit [0..31] go in [0..255] and for 6bit [0..63] do the same.
3) you can change threshold mentioned in the code within the range of [0..31] or shift it accordingly to fit the 5/6 bit : talking about the following part
Code:
      if Pixel.Blue > Threshold then Pixel.Blue := Threshold;
      if Pixel.red > Threshold then Pixel.red := Threshold;
      if Pixel.Green > Threshold then Pixel.Green := Threshold;
after performing the compare and adjust you need to repack the pixel bits, or perform this on the bits directly.

As for 8bit the as above but 8bit bitmap are very rare and almost dead format and most importantly it is very wide in range !, this format or to be more accurate the lack of unified/standardized format goes to 80s and the its color space is might hard to work with,

Why working with 8bit Windows Bitmap (or 8bit DIB) is hard ? because When we talk Windows Bitmap then the there is a table define these 8bit colors representing 256 color value predefined to be used within this 8bit bitmap, so such bitmap will have lookup table with 256 value, the the pixel with grab the value form there, these values can be 8bit, 16bit.. 24bit color value..

Now on bright side for 8bit Windows Bitmap with lookup table, you can adjust the lookup table against the threshold, you don't need to walk the pixels at all !

Hope that help and clear.
  Mit Zitat antworten Zitat