This is IMO a bug in wine.
The problem is that there is no windows function which tells me if the bitmap data in a dibsection is upside down or not. So I use a trick by inverting the first databyte. if the topleft pixel is not changed, the data is upside down. Somehow wine fails this check resulting in a wrong orientation
Hello,
Is not the height (negative or positive) of DIBSection signaling the upside of the lines array ?
Yes, according to the MSDN yes. That's theory, in reality they are always reported positive. Why do you think I added that check ?
I spent weeks reading, searching for official ways, undocumented ways to retrieve this info.
All you find is that getDIBinfo should report the height negative for top to bottom images.
Should... but it doesnt.
Anyway the bug in Wine should be in GetPixel or the function that you use to get the 0,0 pixel do not ?
I readread the code and I thought I used a GetPixel. But the test is more trickier than I thought.
in short:
Through the GetObject() function I get the BITMAP info of a given HBITMAP
If the HBITMAP was created as DIBsection, the BITMAP.bmBits will point to the data of the bitmap. On "real" windows you are allowed to manipulate this data.
For these bmBits I want to know if they are bottom-up or top-down.
With the GetDIBits() function I request the first scanline/pixel in bottom-up order (so it is the last line of the bitmap). I cannot compare it to the value I found in bmBits, since top and bottom may have the same pixelvalue.
Now I invert the first pixel of bmBits and I request again the first scanline in bottom-up order.
If the first pixel did change, then the data was bottom-up.
It the pixel didn't change, I was manipulating the top of the bitmap
There can be a few issues with wine:
1) bmBits points to a copy of the bitmap data
2) GetDIBits doesn't honor the requested scanline order (== doesn't reorder if bottom-up is requested while the image is top-down)
3) Wine does report a negative height, and I think I request a bottom-up but I get a top-down
Only point 3 is something I can fix. I'll add an extra check.