I am trying to find the bits of a bit map so I can mess with the Alpha values.
I have seen this done using oleLoadPicturePath - Nehe style but I do not want to use this as it seems to be overkill when LoadImage will do…is there a simplier way to do it i.e. using GetDIBits?
For storing alpha values a 32 bit pixel format is needed. But GetDIBits(…) failed when I tested by setting 32 to the pixelbits member of the BITMAPINFOHEADER structure . Precise results were obtained
by setting 24 to the pixelbits member and then expanding to output byte array to
32 bit pixel format.
If you need any more help i can send the working code.
The above mentioned statement is for calculating the imagesize in terms of bytes.
In terms of bytes the row length of bitmap must always be a multiple of four and to set this often extra padding bytes are added at the end of the row.
The row length with padding bytes is calculated as follows
((((biWidth * biBitCount) + 31) & ~31) >> 3)
As I understand it the whole bitmaps bits are in a DWORD array. Each “RGB” chunk can be retrieved by “casting” each element into a BYTE, thus giving 4 BYTES to each DWORD element in the array…I think…with it in the order BGRA instead of the standard RGBA.
Now when for a test I copy these values into another array and pass this to glTexImage2D and this works. So I though it would be cool to re-arrange the bits so they are RGBA by simply copying B -> temp and then R -> B and finally temp -> R, i.e. swap R and B via a temp variable…this don’t work.
Also it seems that what I thought was the alpha BYTE…pun not intended…is not the case!
Could anyone explain how the BYTES are arranged? Or am I way off the mark here?
The bitmap bits out of GetDIBits(…) is stored only in the BYTE array and not in a DWORD array. The values from the BYTE array can be easiy copied into the second BYTE array without any typecasing. Only the red and blue values have to be swapped