- Removed last GvG's fix to COMCTL32.

- Implemented proper color -> mono bitmap conversion.

svn path=/trunk/; revision=7128
This commit is contained in:
Filip Navara 2003-12-19 22:58:47 +00:00
parent 9f039ad29c
commit 764ff71a49
6 changed files with 151 additions and 43 deletions

View file

@ -2270,7 +2270,7 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
TRACE ("creating default image list!\n"); TRACE ("creating default image list!\n");
himlDef = ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight, himlDef = ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
ILC_COLOR, nButtons, 2); ILC_COLOR | ILC_MASK, nButtons, 2);
TOOLBAR_InsertImageList(&infoPtr->himlDef, &infoPtr->cimlDef, himlDef, 0); TOOLBAR_InsertImageList(&infoPtr->himlDef, &infoPtr->cimlDef, himlDef, 0);
infoPtr->himlInt = himlDef; infoPtr->himlInt = himlDef;
} }
@ -2314,7 +2314,7 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
DeleteDC (hdcImage); DeleteDC (hdcImage);
DeleteDC (hdcBitmap); DeleteDC (hdcBitmap);
nIndex = ImageList_Add (himlDef, hbmLoad, NULL); nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace);
DeleteObject (hbmLoad); DeleteObject (hbmLoad);
} }
else if (lpAddBmp->hInst == HINST_COMMCTRL) else if (lpAddBmp->hInst == HINST_COMMCTRL)
@ -2325,42 +2325,48 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
case IDB_STD_SMALL_COLOR: case IDB_STD_SMALL_COLOR:
hbmLoad = LoadBitmapA (COMCTL32_hModule, hbmLoad = LoadBitmapA (COMCTL32_hModule,
MAKEINTRESOURCEA(IDB_STD_SMALL)); MAKEINTRESOURCEA(IDB_STD_SMALL));
nIndex = ImageList_Add (himlDef, hbmLoad, NULL); nIndex = ImageList_AddMasked (himlDef,
hbmLoad, comctl32_color.clrBtnFace);
DeleteObject (hbmLoad); DeleteObject (hbmLoad);
break; break;
case IDB_STD_LARGE_COLOR: case IDB_STD_LARGE_COLOR:
hbmLoad = LoadBitmapA (COMCTL32_hModule, hbmLoad = LoadBitmapA (COMCTL32_hModule,
MAKEINTRESOURCEA(IDB_STD_LARGE)); MAKEINTRESOURCEA(IDB_STD_LARGE));
nIndex = ImageList_Add (himlDef, hbmLoad, NULL); nIndex = ImageList_AddMasked (himlDef,
hbmLoad, comctl32_color.clrBtnFace);
DeleteObject (hbmLoad); DeleteObject (hbmLoad);
break; break;
case IDB_VIEW_SMALL_COLOR: case IDB_VIEW_SMALL_COLOR:
hbmLoad = LoadBitmapA (COMCTL32_hModule, hbmLoad = LoadBitmapA (COMCTL32_hModule,
MAKEINTRESOURCEA(IDB_VIEW_SMALL)); MAKEINTRESOURCEA(IDB_VIEW_SMALL));
nIndex = ImageList_Add (himlDef, hbmLoad, NULL); nIndex = ImageList_AddMasked (himlDef,
hbmLoad, comctl32_color.clrBtnFace);
DeleteObject (hbmLoad); DeleteObject (hbmLoad);
break; break;
case IDB_VIEW_LARGE_COLOR: case IDB_VIEW_LARGE_COLOR:
hbmLoad = LoadBitmapA (COMCTL32_hModule, hbmLoad = LoadBitmapA (COMCTL32_hModule,
MAKEINTRESOURCEA(IDB_VIEW_LARGE)); MAKEINTRESOURCEA(IDB_VIEW_LARGE));
nIndex = ImageList_Add (himlDef, hbmLoad, NULL); nIndex = ImageList_AddMasked (himlDef,
hbmLoad, comctl32_color.clrBtnFace);
DeleteObject (hbmLoad); DeleteObject (hbmLoad);
break; break;
case IDB_HIST_SMALL_COLOR: case IDB_HIST_SMALL_COLOR:
hbmLoad = LoadBitmapA (COMCTL32_hModule, hbmLoad = LoadBitmapA (COMCTL32_hModule,
MAKEINTRESOURCEA(IDB_HIST_SMALL)); MAKEINTRESOURCEA(IDB_HIST_SMALL));
nIndex = ImageList_Add (himlDef, hbmLoad, NULL); nIndex = ImageList_AddMasked (himlDef,
hbmLoad, comctl32_color.clrBtnFace);
DeleteObject (hbmLoad); DeleteObject (hbmLoad);
break; break;
case IDB_HIST_LARGE_COLOR: case IDB_HIST_LARGE_COLOR:
hbmLoad = LoadBitmapA (COMCTL32_hModule, hbmLoad = LoadBitmapA (COMCTL32_hModule,
MAKEINTRESOURCEA(IDB_HIST_LARGE)); MAKEINTRESOURCEA(IDB_HIST_LARGE));
nIndex = ImageList_Add (himlDef, hbmLoad, NULL); nIndex = ImageList_AddMasked (himlDef,
hbmLoad, comctl32_color.clrBtnFace);
DeleteObject (hbmLoad); DeleteObject (hbmLoad);
break; break;
@ -2373,7 +2379,7 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
else else
{ {
hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
nIndex = ImageList_Add (himlDef, hbmLoad, NULL); nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace);
DeleteObject (hbmLoad); DeleteObject (hbmLoad);
} }
@ -3924,7 +3930,7 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
DeleteDC (hdcImage); DeleteDC (hdcImage);
DeleteDC (hdcBitmap); DeleteDC (hdcBitmap);
ImageList_Add (himlDef, hbmLoad, NULL); ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace);
nNewBitmaps = ImageList_GetImageCount(himlDef); nNewBitmaps = ImageList_GetImageCount(himlDef);
DeleteObject (hbmLoad); DeleteObject (hbmLoad);
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: objects.h,v 1.21 2003/12/08 18:07:56 fireball Exp $ /* $Id: objects.h,v 1.22 2003/12/19 22:58:47 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -207,16 +207,24 @@ typedef struct _XLATEGDI {
XLATEOBJ XlateObj; XLATEOBJ XlateObj;
HPALETTE DestPal; HPALETTE DestPal;
HPALETTE SourcePal; HPALETTE SourcePal;
ULONG *translationTable;
ULONG RedMask;
ULONG GreenMask;
ULONG BlueMask;
INT RedShift;
INT GreenShift;
INT BlueShift;
BOOL UseShiftAndMask; BOOL UseShiftAndMask;
union {
struct { /* For Shift Translations */
ULONG RedMask;
ULONG GreenMask;
ULONG BlueMask;
INT RedShift;
INT GreenShift;
INT BlueShift;
};
struct { /* For Table Translations */
ULONG *translationTable;
};
struct { /* For Color -> Mono Translations */
ULONG BackgroundColor;
};
};
} XLATEGDI; } XLATEGDI;
// List of GDI objects // List of GDI objects

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: xlate.c,v 1.25 2003/09/26 10:45:44 gvg Exp $ /* $Id: xlate.c,v 1.26 2003/12/19 22:58:47 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -36,6 +36,7 @@
#include <include/object.h> #include <include/object.h>
#include <include/palette.h> #include <include/palette.h>
#include "handle.h" #include "handle.h"
#include <win32k/color.h>
#define NDEBUG #define NDEBUG
#include <win32k/debug1.h> #include <win32k/debug1.h>
@ -410,6 +411,65 @@ XLATEOBJ * STDCALL IntEngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
return XlateObj; return XlateObj;
} }
XLATEOBJ * STDCALL IntEngCreateMonoXlate(
USHORT SourcePalType, HPALETTE PaletteDest, HPALETTE PaletteSource,
ULONG BackgroundColor)
{
HPALETTE NewXlate;
XLATEOBJ *XlateObj;
XLATEGDI *XlateGDI;
PALGDI *SourcePalGDI;
NewXlate = (HPALETTE)CreateGDIHandle(sizeof(XLATEGDI), sizeof(XLATEOBJ));
if (!ValidEngHandle(NewXlate))
return NULL;
XlateObj = (XLATEOBJ *)AccessUserObject((ULONG)NewXlate);
XlateGDI = (XLATEGDI *)AccessInternalObject((ULONG)NewXlate);
ASSERT(XlateObj);
ASSERT(XlateGDI);
XlateObj->iSrcType = SourcePalType;
XlateObj->iDstType = PAL_INDEXED;
// Store handles of palettes in internal Xlate GDI object (or NULLs)
XlateGDI->DestPal = PaletteDest;
XlateGDI->SourcePal = PaletteSource;
XlateObj->flXlate = XO_TO_MONO;
/* FIXME: Map into source palette type */
switch (SourcePalType)
{
case PAL_INDEXED:
XlateGDI->BackgroundColor = NtGdiGetNearestPaletteIndex(
PaletteSource, BackgroundColor);
break;
case PAL_RGB:
XlateGDI->BackgroundColor = BackgroundColor;
break;
case PAL_BGR:
XlateGDI->BackgroundColor =
((BackgroundColor & 0xFF) << 16) |
((BackgroundColor & 0xFF0000) >> 16) |
(BackgroundColor & 0xFF00);
break;
case PAL_BITFIELDS:
{
SourcePalGDI = PALETTE_LockPalette(PaletteSource);
BitMasksFromPal(SourcePalType, SourcePalGDI, &XlateGDI->RedMask,
&XlateGDI->BlueMask, &XlateGDI->GreenMask);
XlateGDI->RedShift = CalculateShift(0xFF0000) - CalculateShift(XlateGDI->RedMask);
XlateGDI->GreenShift = CalculateShift(0xFF00) - CalculateShift(XlateGDI->GreenMask);
XlateGDI->BlueShift = CalculateShift(0xFF) - CalculateShift(XlateGDI->BlueMask);
XlateGDI->BackgroundColor = ShiftAndMask(XlateGDI, BackgroundColor);
PALETTE_UnlockPalette(PaletteSource);
}
break;
}
return XlateObj;
}
/* /*
* @implemented * @implemented
*/ */
@ -434,7 +494,6 @@ XLATEOBJ_iXlate(XLATEOBJ *XlateObj,
ULONG Color) ULONG Color)
{ {
PALGDI *PalGDI; PALGDI *PalGDI;
XLATEGDI *XlateGDI = (XLATEGDI*)AccessInternalObjectFromUserObject(XlateObj);
ULONG Closest; ULONG Closest;
// Return the original color if there's no color translation object // Return the original color if there's no color translation object
@ -444,27 +503,35 @@ XLATEOBJ_iXlate(XLATEOBJ *XlateObj,
{ {
return Color; return Color;
} else } else
if(XlateGDI->UseShiftAndMask)
{ {
return ShiftAndMask(XlateGDI, Color); XLATEGDI *XlateGDI = (XLATEGDI*)AccessInternalObjectFromUserObject(XlateObj);
} else
if (PAL_RGB == XlateObj->iSrcType || PAL_BGR == XlateObj->iSrcType
|| PAL_BITFIELDS == XlateObj->iSrcType)
{
// FIXME: should we cache colors used often?
// FIXME: won't work if destination isn't indexed
// Extract the destination palette if(XlateObj->flXlate & XO_TO_MONO)
PalGDI = PALETTE_LockPalette(XlateGDI->DestPal); {
return Color == XlateGDI->BackgroundColor;
} else
if(XlateGDI->UseShiftAndMask)
{
return ShiftAndMask(XlateGDI, Color);
} else
if (PAL_RGB == XlateObj->iSrcType || PAL_BGR == XlateObj->iSrcType
|| PAL_BITFIELDS == XlateObj->iSrcType)
{
// FIXME: should we cache colors used often?
// FIXME: won't work if destination isn't indexed
// Return closest match for the given color // Extract the destination palette
Closest = ClosestColorMatch(XlateGDI, Color, PalGDI->IndexedColors, PalGDI->NumColors); PalGDI = PALETTE_LockPalette(XlateGDI->DestPal);
PALETTE_UnlockPalette(XlateGDI->DestPal);
return Closest; // Return closest match for the given color
} else Closest = ClosestColorMatch(XlateGDI, Color, PalGDI->IndexedColors, PalGDI->NumColors);
if(XlateObj->iSrcType == PAL_INDEXED) PALETTE_UnlockPalette(XlateGDI->DestPal);
{ return Closest;
return XlateGDI->translationTable[Color]; } else
if(XlateObj->iSrcType == PAL_INDEXED)
{
return XlateGDI->translationTable[Color];
}
} }
return 0; return 0;

View file

@ -40,6 +40,10 @@ XLATEOBJ * STDCALL IntEngCreateXlate(USHORT DestPalType,
USHORT SourcePalType, USHORT SourcePalType,
HPALETTE PaletteDest, HPALETTE PaletteDest,
HPALETTE PaletteSource); HPALETTE PaletteSource);
XLATEOBJ * STDCALL IntEngCreateMonoXlate(
USHORT SourcePalType, HPALETTE PaletteDest, HPALETTE PaletteSource,
ULONG BackgroundColor);
BOOL STDCALL IntEngPolyline(SURFOBJ *DestSurf, BOOL STDCALL IntEngPolyline(SURFOBJ *DestSurf,
CLIPOBJ *Clip, CLIPOBJ *Clip,

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: bitmaps.c,v 1.48 2003/12/08 18:09:08 fireball Exp $ */ /* $Id: bitmaps.c,v 1.49 2003/12/19 22:58:47 navaraf Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
@ -194,7 +194,15 @@ BOOL STDCALL NtGdiBitBlt(HDC hDCDest,
PALETTE_UnlockPalette(DestPalette); PALETTE_UnlockPalette(DestPalette);
} }
XlateObj = (PXLATEOBJ)IntEngCreateXlate(DestMode, SourceMode, DestPalette, SourcePalette); if (DCDest->w.bitsPerPixel == 1)
{
XlateObj = (PXLATEOBJ)IntEngCreateMonoXlate(SourceMode, DestPalette,
SourcePalette, DCSrc->w.backgroundColor);
}
else
{
XlateObj = (PXLATEOBJ)IntEngCreateXlate(DestMode, SourceMode, DestPalette, SourcePalette);
}
if (NULL == XlateObj) if (NULL == XlateObj)
{ {
if (UsesSource && hDCSrc != hDCDest) if (UsesSource && hDCSrc != hDCDest)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: color.c,v 1.29 2003/12/14 21:32:52 navaraf Exp $ */ /* $Id: color.c,v 1.30 2003/12/19 22:58:47 navaraf Exp $ */
// FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping // FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping
@ -302,17 +302,32 @@ COLORREF STDCALL NtGdiGetNearestColor(HDC hDC,
UINT STDCALL NtGdiGetNearestPaletteIndex(HPALETTE hpal, UINT STDCALL NtGdiGetNearestPaletteIndex(HPALETTE hpal,
COLORREF Color) COLORREF Color)
{ {
#if 1
PPALGDI palGDI = (PPALGDI) PALETTE_LockPalette(hpal);
UINT index = 0;
if (NULL != palGDI)
{
/* Return closest match for the given RGB color */
index = COLOR_PaletteLookupPixel((LPPALETTEENTRY)palGDI->IndexedColors, palGDI->NumColors, NULL, Color, FALSE);
PALETTE_UnlockPalette(hpal);
}
return index;
#else
PPALOBJ palObj = (PPALOBJ) PALETTE_LockPalette(hpal); PPALOBJ palObj = (PPALOBJ) PALETTE_LockPalette(hpal);
UINT index = 0; UINT index = 0;
if (NULL != palObj) if (NULL != palObj)
{ {
/* Return closest match for the given RGB color */ /* Return closest match for the given RGB color */
ASSERT(palObj->logpalette != NULL);
index = COLOR_PaletteLookupPixel(palObj->logpalette->palPalEntry, palObj->logpalette->palNumEntries, NULL, Color, FALSE); index = COLOR_PaletteLookupPixel(palObj->logpalette->palPalEntry, palObj->logpalette->palNumEntries, NULL, Color, FALSE);
PALETTE_UnlockPalette(hpal); PALETTE_UnlockPalette(hpal);
} }
return index; return index;
#endif
} }
UINT STDCALL NtGdiGetPaletteEntries(HPALETTE hpal, UINT STDCALL NtGdiGetPaletteEntries(HPALETTE hpal,