Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is rgbReserved?

Hi there I want to know what is this rgbReserved in RGBQuadArray and why when I change RGB colors there are some ugly lines displayed on the image? Is it related to rgbReserved?

like image 773
Javid Avatar asked Dec 21 '22 20:12

Javid


1 Answers

In memory, a line of a bitmap is often stored in the format BBGGRR00BBGGRR00BBGGRR00... so that each pixel will occupy exactly four bytes, or 32 bits. This simplifies a lot of things, and can speed up computations and image manipulation. But if the bitmap specifies the red, green, and blue intensities as bytes (in the range 0..255), and doesn't contain an alpha channel, then each pixel will only need three bytes. So there is a forth unused byte per pixel. And in the pixel structure it's got to be named something. Given that the usable members are called rgbRed, rgbGreen, and rgbBlue, rgbReserved feels rather OK. Maybe rgbUnused would be even more suitable, but there is a tradition in Win32 to name (currently) unused parameters "Reserved", as in "reserved for future use". In fact, if you app works with transparent bitmaps containing an alpha channel, each pixel might be of the form BBGGRRAA, so you could use the rgbReserved as rgbAlpha.

The latter part of your question cannot be answered as it stands. I have no idea why your code doesn't work. Maybe the pixel intensities are overflowing? Maybe there is some silly bug somewhere?

As a final note: If you wonder what a member of a Win32 structure is, you can always consult the official documentation.

like image 55
Andreas Rejbrand Avatar answered Jan 01 '23 19:01

Andreas Rejbrand