PRB: Bitmap Displays Upside Down Using StretchDIBits
ID: Q151920
|
The information in this article applies to:
-
Microsoft Win32 Software Development Kit (SDK), used with:
-
Microsoft Windows NT 3.51
-
Microsoft Windows 95
SYMPTOMS
Calling StretchDIBits on a DIB causes it to display upside down.
CAUSE
Two situations could cause a bitmap to display upside down in Win32:
- The signs of the cxSrc and cxDest parameters differ. The documentation for StretchDIBits states that the function creates a mirror image of a bitmap along the x-axis if the signs of the cxSrc and cxDest parameters differ. Whether intentional or unintentional, this could cause a bitmap to display upside down.
- The sign of the biHeight value in the BITMAPINFOHEADER does not correctly reflect how the bitmap bits are stored in the DIB file. In Win16, all DIBs are stored bottom-up, with the bottom-most scan line stored first in the DIB file. In Win32, DIBs may also be stored top-down, with the top-most scan line stored first. Top-down DIBs are denoted by a negative biHeight value in the BITMAPINFOHEADER structure; bottom-up DIBS are denoted by a positive biHeight value:
DIB stored as Should have a biHeight value of
------------- -------------------------------
top-down negative
bottom-up positive
Make sure the biHeight value is appropriately set as positive or negative,
depending on how the bitmap bits were stored in the DIB file. A mismatch in
the way this value is set could result to an upside down bitmap because the
DIB engine interprets the bits incorrectly. For example, a positive
biHeight value for a DIB stored as top-down should cause a bitmap to
display upside down.
STATUS
This behavior is by design.
Additional query words:
4.00 3.51 inverted reverse
Keywords : kbNTOS351 kbSDKWin32 kbWinOS95 kbDSupport
Version : WINDOWS:95
Platform : WINDOWS
Issue type : kbprb