problem witrh top-down vs. bottom-up bitmaps

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem witrh top-down vs. bottom-up bitmaps

Jochen Riekhof-3
Hi...

when loading DIBSections from file vs. creating one in dolphin I encountered
a weird bug. While my loaded bmps are all bottom up the ones created by
dolphin are top-down. Windows uses negative biHeight in BITMAPINFOHEADER to
indicate top-down. This is nicely to be observed in the code as height is
negated on writing to BITMAPINFOHEADER in DIBSection>>createHandle. All fine
spo far, but here it comes:
When I later look into DIBSection>>getDIBSECTION, I find always positive
biHeight regardless of top-down or bottom-up. So, I have no way to determine
this status.
I guess the problem is the reading of the BITMAPINFOHEADER, not the setup,
as the images work all fine.

Ciao

...Jochen


Reply | Threaded
Open this post in threaded view
|

Re: problem witrh top-down vs. bottom-up bitmaps

Jochen Riekhof
´Hum, made some weird code to check the bottom-up condition. Cache pixel
values of pixels at 0@0 and 0@(height-1).
Write defined value1 to 0@0 and defined (different!) value 2 to
0@(height-1), all with my own fast pixel access routines.
Then read pixel at 0@0 with canvas pixelAt: method. If the value is the one
written with fast method to 0@0 it's top-down, otherwise bottom-up. Finally
restore cached values.

Awkward, but works. If anybody has time to check if the same
BITMAPINFOHEADER bug on reread of the DIBsSection with GDIs getObject()  is
showing up in C++, too, I would be interested in the outcome!

Ciao

...Jochen