I'm well and truely stuck today.. 2 questions in one day !!

OK.. I'm trying to work out how to rotate a DDE bitmap by 180 degrees.. see the attached picture.. as you can see, I'd much rather view europe the usual way up, which means a 180 degree rotation of the bitmap.. but here is the problem.. :

The bit map is created only at several lines at a time. i.e. the whole of the DIB does not reside at all anywhere ... lines are decoded only several at a time, an set into a DDE bitmap with SetDIBits.

So my Idea is to get the DIBits using the GetDIBits, once having got the bits manipulating as necessary and then setting back into the bitmap once again using SetDIBits.

However it doesn't work.

GetDIBits returns bits, but no longer the correct type of colours.. I just don't understand how GetDIBits works really.. i've included the resulting picture as well. It appears to me that the colour table has been reduced from the original 16 greyscales to 4... why ?? I didn't ask for that !!

Does anyone know of code examples for the use of GetDIBits ?? I'm completely lost. Every time I try to use bitmaps I get confused. the win32 docs just confuse me .. and raise more questions than they answer for me !


Posted on 2003-01-09 17:04:42 by CodeBug
i meant to attatch the zip file of images
Posted on 2003-01-09 17:07:18 by CodeBug
GetDIBits allows you to specify the format of the data you want to retrieve. Just set it to 24/32-bit and the colors should be correct. For some examples search the board for GetDIBits.

Posted on 2003-01-11 04:15:55 by Thomas
Thanks Thomas for your reply,

It finally dawned on me where the problem lay.

Although I created the image as a 4bpp DIB, the final DDB had been built up several lines at a time from the DIB, as the bits in the DIB too are drawn only a few lines at a time. After i converted each group of lines to the DDB, i simply discarded the DIB lines, leaving me with only a DDB. This is fine as long as I don't want to do any colour processing with the final image, this requires.. to make life easier.. the DIB.

However to rotate the DDB I still need access to the bitmap bits and I thought GetDIBits would do this for me, bringing it BACK to an 4bpp DIB, but it can't. IT returns a 32 bpp (or 16 bit as I found out after changing the settings of the display card). In this respect.. GetDIBits does NOT do as the docs say (or is it me no understanding the docs ???) .. for some reson.. when I do as for a 4bpp it returns with less then 16 colours (or grey scales in my case)

(I would like to hear from anyone else who has comments on the GetDIBits function)

It appears my mistake was to discard the DIB. But thats ok for now.. as I only need to rotate the picture.. no colour processing required at this point

Posted on 2003-01-11 04:59:16 by CodeBug