Author: tkreuzer
Date: Sun Feb 27 17:20:02 2011
New Revision: 50918
URL:
http://svn.reactos.org/svn/reactos?rev=50918&view=rev
Log:
[GDI32]
In GetDIBits convert a BITMAPCOREHEADER to a BITMAPINFOHEADER before calling win32k, like
done in other places. Convert it back after. This allows to simplify
NtGdiGetDIBitsInternal (not done yet)
Modified:
trunk/reactos/dll/win32/gdi32/objects/bitmap.c
Modified: trunk/reactos/dll/win32/gdi32/objects/bitmap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/bi…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] Sun Feb 27 17:20:02 2011
@@ -410,6 +410,33 @@
return CreateDIBSection(hDC, (CONST BITMAPINFO *)&dibs.dsBmih, 0, NULL, NULL,
0);
}
+void
+ConvertBackBitmapInfo(PBITMAPINFO pbmi, PBITMAPINFO pbmiConverted)
+{
+ /* Check if we converted from PBITMAPCOREINFO */
+ if (pbmiConverted != pbmi)
+ {
+ PBITMAPCOREINFO pbci = (PBITMAPCOREINFO)pbmi;
+
+ /* Convert back header */
+ pbci->bmciHeader.biSize = sizeof(BITMAPCOREHEADER);
+ pbci->bmciHeader.bcWidth = pbmiConverted->bmiHeader.biWidth;
+ pbci->bmciHeader.bcHeight = pbmiConverted->bmiHeader.biHeight;
+ pbci->bmciHeader.bcPlanes = 1;
+ pbci->bmciHeader.bcBitCount = pbmiConverted->bmiHeader.biBitCount;
+
+ /* Convert back colors */
+ for (i = 0; i < pbmiConverted->bmiHeader.biClrUsed; i++)
+ {
+ pbci->bmciColors.rgbtRed = pbmiConverted->bmiColors.rgbRed;
+ pbci->bmciColors.rgbtGreen = pbmiConverted->bmiColors.rgbGreen;
+ pbci->bmciColors.rgbtBlue = pbmiConverted->bmiColors.rgbBlue;
+ }
+
+ /* Free memory */
+ RtlFreeHeap(RtlGetProcessHeap(), 0, pbmiConverted);
+ }
+}
INT
WINAPI
@@ -422,8 +449,9 @@
LPBITMAPINFO lpbmi,
UINT uUsage)
{
- UINT cjBmpScanSize;
- UINT cjInfoSize;
+ PBITMAPINFO pbmiConverted;
+ UINT cjBmpScanSize, cjInfoSize;
+ INT iResult;
if (!hDC || !GdiIsHandleValid((HGDIOBJ)hDC) || !lpbmi)
{
@@ -431,15 +459,22 @@
return 0;
}
+ /* Convert BITMAPINFO to a proper format */
+ pbmiConverted = ConvertBitmapInfo(lpbmi, uUsage, &cjInfoSize, FALSE);
+ if (!pbmiConverted)
+ {
+ GdiSetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
cjBmpScanSize = DIB_BitmapMaxBitsSize(lpbmi, cScanLines);
- cjInfoSize = DIB_BitmapInfoSize(lpbmi, uUsage);
-
- if ( lpvBits )
- {
- if ( lpbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER) )
- {
- if ( lpbmi->bmiHeader.biCompression == BI_JPEG ||
- lpbmi->bmiHeader.biCompression == BI_PNG )
+
+ if (lpvBits)
+ {
+ if (lpbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER))
+ {
+ if (lpbmi->bmiHeader.biCompression == BI_JPEG ||
+ lpbmi->bmiHeader.biCompression == BI_PNG)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
@@ -447,16 +482,21 @@
}
}
- return NtGdiGetDIBitsInternal(hDC,
- hbmp,
- uStartScan,
- cScanLines,
- lpvBits,
- lpbmi,
- uUsage,
- cjBmpScanSize,
- cjInfoSize);
-}
+ iResult = NtGdiGetDIBitsInternal(hDC,
+ hbmp,
+ uStartScan,
+ cScanLines,
+ lpvBits,
+ pbmiConverted,
+ uUsage,
+ cjBmpScanSize,
+ cjInfoSize);
+
+ ConvertBackBitmapInfo(lpbmi, pbmiConverted);
+
+ return iResult;
+}
+
/*
* @implemented