Author: khornicek
Date: Sat Nov 21 22:54:17 2009
New Revision: 44263
URL:
http://svn.reactos.org/svn/reactos?rev=44263&view=rev
Log:
- palette support for dib sections
Modified:
branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c
branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c
branches/arwinss/reactos/subsystems/win32/win32k/gre/brushobj.c
branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c
branches/arwinss/reactos/subsystems/win32/win32k/include/brushobj.h
branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] Sat Nov 21
22:54:17 2009
@@ -130,6 +130,9 @@
SIZEL szSize;
ULONG ulFormat;
HBITMAP hbmDIB;
+ RGBQUAD *lpRGB = NULL;
+ PDC pDC;
+ SURFACE *dibSurf;
/* Get DIB section size */
szSize.cx = dib->dsBm.bmWidth;
@@ -145,6 +148,52 @@
BMF_DONTCACHE | BMF_USERMEM | BMF_NOZEROINIT |
0,
dib->dsBm.bmBits);
+
+ dib->dsBmih.biClrUsed = 0;
+ /* set number of entries in bmi.bmiColors table */
+ if (dib->dsBmih.biBitCount == 1)
+ {
+ dib->dsBmih.biClrUsed = 2;
+ }
+ else if (dib->dsBmih.biBitCount == 4)
+ {
+ dib->dsBmih.biClrUsed = 16;
+ }
+ else if (dib->dsBmih.biBitCount == 8)
+ {
+ dib->dsBmih.biClrUsed = 256;
+ }
+
+ dibSurf = SURFACE_Lock(hbmDIB);
+
+ if (dib->dsBmih.biClrUsed != 0)
+ {
+ if (usage == DIB_PAL_COLORS)
+ {
+ pDC = DC_Lock(physDev);
+ lpRGB = DIB_MapPaletteColors(pDC, bmi);
+ DC_Unlock(pDC);
+ dibSurf->hDIBPalette =
PALETTE_AllocPaletteIndexedRGB(dib->dsBmih.biClrUsed, lpRGB);
+ }
+ else
+ {
+ dibSurf->hDIBPalette =
PALETTE_AllocPaletteIndexedRGB(dib->dsBmih.biClrUsed, bmi->bmiColors);
+ }
+ }
+ else
+ {
+ dibSurf->hDIBPalette = PALETTE_AllocPalette(PAL_BITFIELDS, 0, NULL,
+ dib->dsBitfields[0],
+ dib->dsBitfields[1],
+ dib->dsBitfields[2]);
+ }
+
+ SURFACE_Unlock(dibSurf);
+
+ if (lpRGB)
+ {
+ ExFreePoolWithTag(lpRGB, TAG_COLORMAP);
+ }
/* Map handles */
GDI_AddHandleMapping(hbmDIB, hbitmap);
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] Sat Nov 21
22:54:17 2009
@@ -303,7 +303,7 @@
case BS_SOLID:
DPRINT("BS_SOLID\n" );
- pDC->pFillBrush = GreCreateSolidBrush(pLogBrush->lbColor);
+ pDC->pFillBrush = GreCreateSolidBrush(pDC->pBitmap->hDIBPalette,
pLogBrush->lbColor);
break;
case BS_HATCHED:
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/brushobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/brushobj.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/brushobj.c [iso-8859-1] Sat Nov
21 22:54:17 2009
@@ -187,7 +187,7 @@
PBRUSHGDI
NTAPI
-GreCreateSolidBrush(COLORREF crColor)
+GreCreateSolidBrush(HPALETTE hDIBPalette, COLORREF crColor)
{
PBRUSHGDI pBrush;
XLATEOBJ *pXlate;
@@ -201,8 +201,11 @@
pBrush->flAttrs |= GDIBRUSH_IS_SOLID;
/* Set color */
- // FIXME: Take hDIBPalette in account if it exists!
- hPalette = pPrimarySurface->DevInfo.hpalDefault;
+ if(hDIBPalette)
+ hPalette = hDIBPalette;
+ else
+ hPalette = pPrimarySurface->DevInfo.hpalDefault;
+
pXlate = IntEngCreateXlate(0, PAL_RGB, hPalette, NULL);
pBrush->BrushObj.iSolidColor = XLATEOBJ_iXlate(pXlate, crColor);
EngDeleteXlate(pXlate);
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c [iso-8859-1] Sat Nov 21
22:54:17 2009
@@ -333,7 +333,7 @@
PBRUSHGDI pOldBrush = pDC->pFillBrush;
/* Create a solid brush with this color */
- pDC->pFillBrush = GreCreateSolidBrush(crColor);
+ pDC->pFillBrush = GreCreateSolidBrush(pDC->pBitmap->hDIBPalette, crColor);
/* Put pixel */
GrePatBlt(pDC, x, y, 1, 1, PATCOPY, pDC->pFillBrush);
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/brushobj.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/brushobj.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/brushobj.h [iso-8859-1] Sat
Nov 21 22:54:17 2009
@@ -60,7 +60,7 @@
GreCreateHatchedBrush(INT iHatchStyle, COLORREF crColor);
PBRUSHGDI NTAPI
-GreCreateSolidBrush(COLORREF crColor);
+GreCreateSolidBrush(HPALETTE hDIBPalette, COLORREF crColor);
PBRUSHGDI NTAPI
GreCreatePatternBrush(HBITMAP hbmPattern);
Modified: branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c [iso-8859-1] Sat Nov 21
22:54:17 2009
@@ -878,7 +878,7 @@
RosGdiCreateDC(&RosDc, &ScreenDc, L"", L"",
L"", NULL);
/* Create a pen and select it */
- Brush = GreCreateSolidBrush(RGB(0xFF, 0, 0));
+ Brush = GreCreateSolidBrush(NULL, RGB(0xFF, 0, 0));
/* Get a pointer to the DC */
pDC = DC_Lock(ScreenDc);
@@ -897,7 +897,7 @@
/* Clear the area */
BrushBack = pDC->pFillBrush;
- pDC->pFillBrush = GreCreateSolidBrush(RGB(0,0,0));
+ pDC->pFillBrush = GreCreateSolidBrush(NULL, RGB(0,0,0));
GreRectangle(pDC, 0, 0, 800/4, 600/4);
GreFreeBrush(pDC->pFillBrush);
pDC->pFillBrush = BrushBack;