Author: fireball
Date: Thu Apr 2 21:25:56 2009
New Revision: 40331
URL:
http://svn.reactos.org/svn/reactos?rev=40331&view=rev
Log:
- NtGdiSetDIBitsToDeviceInternal: use bitmap's palette if it exists instead of always
using system palette. Based on a patch by Evgeniy Boltik from bug 4326.
See issue #4326 for more details.
Modified:
trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Thu Apr 2
21:25:56 2009
@@ -437,6 +437,7 @@
PDC pDC;
HBITMAP hSourceBitmap = NULL;
SURFOBJ *pDestSurf, *pSourceSurf = NULL;
+ SURFACE *pSurf;
RECTL rcDest;
POINTL ptSource;
INT DIBWidth;
@@ -476,13 +477,18 @@
return 0;
}
+ /* Use destination palette obtained from the DC by default */
+ DDBPalette = pDC->ppdev->DevInfo.hpalDefault;
+
+ /* Try to use hDIBPalette if it exists */
+ pSurf = SURFACE_LockSurface(pDC->rosdc.hBitmap);
+ if (pSurf && pSurf->hDIBPalette)
+ {
+ DDBPalette = pSurf->hDIBPalette;
+ SURFACE_UnlockSurface(pSurf);
+ }
+
pDestSurf = EngLockSurface((HSURF)pDC->rosdc.hBitmap);
- if (!pDestSurf)
- {
- /* FIXME: SetLastError ? */
- DC_UnlockDc(pDC);
- return 0;
- }
rcDest.left = XDest;
rcDest.top = YDest;
@@ -521,8 +527,8 @@
goto Exit;
}
- /* Obtain destination palette from the DC */
- pDCPalette = PALETTE_LockPalette(pDC->ppdev->DevInfo.hpalDefault);
+ /* Obtain destination palette */
+ pDCPalette = PALETTE_LockPalette(DDBPalette);
if (!pDCPalette)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
@@ -531,7 +537,6 @@
}
DDBPaletteType = pDCPalette->Mode;
- DDBPalette = pDC->ppdev->DevInfo.hpalDefault;
PALETTE_UnlockPalette(pDCPalette);
DIBPalette = BuildDIBPalette(bmi, (PINT)&DIBPaletteType);