Microsoft KB Archive/186586

{|
 * width="100%"|

PRB: GetObject Always Returns Positive Height For DIB Sections

 * }

Q186586

-

The information in this article applies to:


 * Microsoft Windows NT Server version 4.0
 * Microsoft Windows NT Workstation version 4.0
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Professional

-

SYMPTOMS
When you use GetObject to obtain information about a DIB section, GetObject always returns a DIBSECTION containing a BITMAPINFOHEADER with a positive height value, regardless of the sign of the height it was created with. If you need to track the sign of the height in an application, you will need to do this programmatically.

MORE INFORMATION
The following code demonstrates this problem:

Sample Code
  // Code to create a DIB section that will be used as   // a test case. HBITMAP CreateADIBSection(int iWidth, int iHeight) {      BITMAPINFO bmi; BYTE *pBits; HDC hdc = GetDC(NULL); HBITMAP hbm;

      // Initialize the header. bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth = iWidth; bmi.bmiHeader.biHeight = iHeight; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 24; bmi.bmiHeader.biCompression = BI_RGB;

      // Create the surface. hbm = CreateDIBSection(hdc,       // Handle to device context.                              &bmi,       // Pointer to creation parameters                              DIB_RGB_COLORS,   // Unused.                              &pBits,     // Address of pointer to surface.                              NULL,       // No file mapping object.                              0);         // No offset.

      // Clean up. ReleaseDC(NULL, hdc);

"return(hbm);"   }

  // Create a DIB section with a negative height, and then // display its height as returned from GetObject. {      char       szMessage[128]; int       nHeight = -100; HBITMAP   hbm = CreateADIBSection(10, nHeight); // Create a test // case. DIBSECTION ds;

      // Fill out a DIBSECTION for the test case. GetObject(hbm, sizeof(ds), &ds);

"wsprintf(szMessage, 'Created with height: %li\n' 'Height reported by GetObject: %li', nHeight, ds.dsBmih.biHeight);"

"MessageBox(NULL, szMessage, 'Status...', MB_ICONINFORMATION);"   } Additional query words: kbdsd kbGDI kbBitmap kbDSupport

Keywords : _IK kbOSWin2000 kbGDIFAQ

Issue type : kbprb

Technology : kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT400xsearch kbwin2000AdvServ kbwin2000AdvServSearch kbwin2000Serv kbWinNTSsearch kbWinNTS400xsearch kbWinNTS400 kbwin2000ServSearch kbwin2000Search kbwin2000ProSearch kbwin2000Pro kbWinAdvServSearch