mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
- Fix various bitmap format translation bugs
- Fix some palette issues - Fix some gdiobj locking warnings svn path=/trunk/; revision=5950
This commit is contained in:
parent
e9170f21ca
commit
f62b36b0f1
10 changed files with 329 additions and 478 deletions
|
@ -171,7 +171,6 @@ HGDIOBJ STDCALL NtGdiGetCurrentObject(HDC hDC, UINT ObjectType);
|
|||
VOID FASTCALL IntGetCurrentPositionEx (PDC dc, LPPOINT currentPosition);
|
||||
BOOL STDCALL NtGdiGetCurrentPositionEx(HDC hDC, LPPOINT currentPosition);
|
||||
BOOL STDCALL NtGdiGetDCOrgEx(HDC hDC, LPPOINT Point);
|
||||
HDC STDCALL NtGdiGetDCState16(HDC hDC);
|
||||
INT STDCALL NtGdiGetDeviceCaps(HDC hDC, INT Index);
|
||||
INT STDCALL NtGdiGetMapMode(HDC hDC);
|
||||
INT STDCALL NtGdiGetObject(HGDIOBJ hGDIObj,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: dib16bpp.c,v 1.7 2003/08/13 20:24:04 chorns Exp $ */
|
||||
/* $Id: dib16bpp.c,v 1.8 2003/08/31 07:56:24 gvg Exp $ */
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -179,9 +179,42 @@ DIB_16BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
|||
}
|
||||
else
|
||||
{
|
||||
/* FIXME */
|
||||
DPRINT1("DIB_16BPP_Bitblt: Unhandled ColorTranslation for 16 -> 16 copy");
|
||||
return FALSE;
|
||||
if (DestRect->top < SourcePoint->y)
|
||||
{
|
||||
SourceLine = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 2 * SourcePoint->x;
|
||||
DestLine = DestBits;
|
||||
for (j = DestRect->top; j < DestRect->bottom; j++)
|
||||
{
|
||||
SourceBits = SourceLine;
|
||||
DestBits = DestLine;
|
||||
for (i = DestRect->left; i < DestRect->right; i++)
|
||||
{
|
||||
*((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(ColorTranslation, *((WORD *)SourceBits));
|
||||
SourceBits += 2;
|
||||
DestBits += 2;
|
||||
}
|
||||
SourceLine += SourceSurf->lDelta;
|
||||
DestLine += DestSurf->lDelta;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SourceLine = SourceSurf->pvScan0 + ((SourcePoint->y + DestRect->bottom - DestRect->top - 1) * SourceSurf->lDelta) + 2 * SourcePoint->x;
|
||||
DestLine = DestSurf->pvScan0 + ((DestRect->bottom - 1) * DestSurf->lDelta) + 2 * DestRect->left;
|
||||
for (j = DestRect->bottom - 1; DestRect->top <= j; j--)
|
||||
{
|
||||
SourceBits = SourceLine;
|
||||
DestBits = DestLine;
|
||||
for (i = DestRect->left; i < DestRect->right; i++)
|
||||
{
|
||||
*((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(ColorTranslation, *((WORD *)SourceBits));
|
||||
SourceBits += 2;
|
||||
DestBits += 2;
|
||||
}
|
||||
SourceLine -= SourceSurf->lDelta;
|
||||
DestLine -= DestSurf->lDelta;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: dib8bpp.c,v 1.5 2003/08/13 20:24:04 chorns Exp $ */
|
||||
/* $Id: dib8bpp.c,v 1.6 2003/08/31 07:56:24 gvg Exp $ */
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -156,9 +156,38 @@ DIB_8BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
|||
}
|
||||
else
|
||||
{
|
||||
/* FIXME */
|
||||
DPRINT1("DIB_8BPP_Bitblt: Unhandled ColorTranslation for 32 -> 32 copy");
|
||||
return FALSE;
|
||||
if (DestRect->top < SourcePoint->y)
|
||||
{
|
||||
SourceLine = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x;
|
||||
DestLine = DestBits;
|
||||
for (j = DestRect->top; j < DestRect->bottom; j++)
|
||||
{
|
||||
SourceBits = SourceLine;
|
||||
DestBits = DestLine;
|
||||
for (i=DestRect->left; i<DestRect->right; i++)
|
||||
{
|
||||
*DestBits++ = XLATEOBJ_iXlate(ColorTranslation, *SourceBits++);
|
||||
}
|
||||
SourceLine += SourceSurf->lDelta;
|
||||
DestLine += DestSurf->lDelta;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SourceLine = SourceSurf->pvScan0 + ((SourcePoint->y + DestRect->bottom - DestRect->top - 1) * SourceSurf->lDelta) + SourcePoint->x;
|
||||
DestLine = DestSurf->pvScan0 + ((DestRect->bottom - 1) * DestSurf->lDelta) + DestRect->left;
|
||||
for (j = DestRect->bottom - 1; DestRect->top <= j; j--)
|
||||
{
|
||||
SourceBits = SourceLine;
|
||||
DestBits = DestLine;
|
||||
for (i=DestRect->left; i<DestRect->right; i++)
|
||||
{
|
||||
*DestBits++ = XLATEOBJ_iXlate(ColorTranslation, *SourceBits++);
|
||||
}
|
||||
SourceLine -= SourceSurf->lDelta;
|
||||
DestLine -= DestSurf->lDelta;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: copybits.c,v 1.17 2003/08/04 19:57:05 royce Exp $
|
||||
/* $Id: copybits.c,v 1.18 2003/08/31 07:56:24 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -119,10 +119,6 @@ EngCopyBits(SURFOBJ *Dest,
|
|||
clippingType = Clip->iDComplexity;
|
||||
}
|
||||
|
||||
// We only handle XO_TABLE translations at the momement
|
||||
if ((ColorTranslation == NULL) || (ColorTranslation->flXlate & XO_TRIVIAL) ||
|
||||
(ColorTranslation->flXlate & XO_TABLE))
|
||||
{
|
||||
SourceGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Source);
|
||||
DestGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Dest);
|
||||
|
||||
|
@ -184,11 +180,11 @@ EngCopyBits(SURFOBJ *Dest,
|
|||
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
MouseSafetyOnDrawEnd(Source, SourceGDI);
|
||||
MouseSafetyOnDrawEnd(Dest, DestGDI);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: xlate.c,v 1.23 2003/08/28 12:35:59 gvg Exp $
|
||||
/* $Id: xlate.c,v 1.24 2003/08/31 07:56:24 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -101,16 +101,11 @@ ClosestColorMatch(XLATEGDI *XlateGDI, ULONG SourceColor, ULONG *DestColors,
|
|||
return CCMLastColorMatch;
|
||||
}
|
||||
|
||||
if (PAL_BITFIELDS == XlateGDI->XlateObj.iSrcType)
|
||||
if (PAL_BITFIELDS == XlateGDI->XlateObj.iSrcType || PAL_BGR == XlateGDI->XlateObj.iSrcType)
|
||||
{
|
||||
/* FIXME: must use bitfields */
|
||||
SourceRGB = ShiftAndMask(XlateGDI, SourceColor);
|
||||
cSourceColor = (PVIDEO_CLUTDATA) &SourceRGB;
|
||||
/*
|
||||
SourceRed = (SourceColor >> 7) & 0xff;
|
||||
SourceGreen = (SourceColor >> 2) & 0xff;
|
||||
SourceBlue = (SourceColor << 3) & 0xff;
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -119,6 +114,7 @@ ClosestColorMatch(XLATEGDI *XlateGDI, ULONG SourceColor, ULONG *DestColors,
|
|||
SourceRed = cSourceColor->Red;
|
||||
SourceGreen = cSourceColor->Green;
|
||||
SourceBlue = cSourceColor->Blue;
|
||||
|
||||
for (i=0; i<NumColors; i++)
|
||||
{
|
||||
cDestColors = (PVIDEO_CLUTDATA)&DestColors[i];
|
||||
|
@ -150,10 +146,17 @@ IndexedToIndexedTranslationTable(XLATEGDI *XlateGDI, ULONG *TranslationTable,
|
|||
PALGDI *PalDest, PALGDI *PalSource)
|
||||
{
|
||||
ULONG i;
|
||||
WINBOOL Trivial;
|
||||
|
||||
Trivial = TRUE;
|
||||
for(i=0; i<PalSource->NumColors; i++)
|
||||
{
|
||||
TranslationTable[i] = ClosestColorMatch(XlateGDI, PalSource->IndexedColors[i], PalDest->IndexedColors, PalDest->NumColors);
|
||||
Trivial = Trivial && (TranslationTable[i] == i);
|
||||
}
|
||||
if (Trivial)
|
||||
{
|
||||
XlateGDI->XlateObj.flXlate |= XO_TRIVIAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,7 +304,7 @@ XLATEOBJ * STDCALL IntEngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
|
|||
}
|
||||
|
||||
// Prepare the translation table
|
||||
if( (SourcePalType == PAL_INDEXED) || (SourcePalType == PAL_RGB) )
|
||||
if (PAL_INDEXED == SourcePalType || PAL_RGB == SourcePalType || PAL_BGR == SourcePalType)
|
||||
{
|
||||
XlateObj->flXlate |= XO_TABLE;
|
||||
if ((SourcePalType == PAL_INDEXED) && (DestPalType == PAL_INDEXED))
|
||||
|
@ -333,13 +336,7 @@ XLATEOBJ * STDCALL IntEngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
|
|||
|
||||
// Converting from indexed to RGB
|
||||
|
||||
#ifdef TODO
|
||||
XLATEOBJ_cGetPalette(XlateObj, XO_SRCPALETTE,
|
||||
SourcePalGDI->NumColors,
|
||||
XlateGDI->translationTable);
|
||||
#else
|
||||
RtlCopyMemory(XlateGDI->translationTable, SourcePalGDI->IndexedColors, sizeof(ULONG) * SourcePalGDI->NumColors);
|
||||
#endif
|
||||
if (PAL_BITFIELDS == XlateObj->iDstType)
|
||||
{
|
||||
for (i = 0; i < SourcePalGDI->NumColors; i++)
|
||||
|
@ -353,19 +350,15 @@ XLATEOBJ * STDCALL IntEngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
|
|||
}
|
||||
|
||||
// Source palette is RGB
|
||||
if(XlateObj->iSrcType == PAL_RGB)
|
||||
if (PAL_RGB == XlateObj->iSrcType || PAL_BGR == XlateObj->iSrcType)
|
||||
{
|
||||
if(XlateObj->iDstType == PAL_INDEXED)
|
||||
if(PAL_INDEXED == XlateObj->iDstType)
|
||||
{
|
||||
// FIXME: Is this necessary? I think the driver has to call this
|
||||
// function anyways if pulXlate is NULL and Dest is PAL_INDEXED
|
||||
|
||||
// Converting from RGB to indexed
|
||||
#ifdef TODO
|
||||
XLATEOBJ_cGetPalette(XlateObj, XO_DESTPALETTE, DestPalGDI->NumColors, XlateGDI->translationTable);
|
||||
#else
|
||||
RtlCopyMemory(XlateGDI->translationTable, DestPalGDI->IndexedColors, sizeof(ULONG) * DestPalGDI->NumColors);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -433,7 +426,8 @@ XLATEOBJ_iXlate(XLATEOBJ *XlateObj,
|
|||
{
|
||||
return ShiftAndMask(XlateGDI, Color);
|
||||
} else
|
||||
if(PAL_RGB == XlateObj->iSrcType || PAL_BITFIELDS == XlateObj->iSrcType)
|
||||
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
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: bitmaps.c,v 1.37 2003/08/28 12:35:59 gvg Exp $ */
|
||||
/* $Id: bitmaps.c,v 1.38 2003/08/31 07:56:24 gvg Exp $ */
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -54,8 +54,7 @@ BOOL STDCALL NtGdiBitBlt(HDC hDCDest,
|
|||
POINTL SourcePoint;
|
||||
//PBITMAPOBJ DestBitmapObj;
|
||||
//PBITMAPOBJ SrcBitmapObj;
|
||||
BOOL Status, SurfDestAlloc, SurfSrcAlloc, XlateAlloc;
|
||||
PPALOBJ DCLogPal;
|
||||
BOOL Status, SurfDestAlloc, SurfSrcAlloc;
|
||||
PPALGDI PalDestGDI, PalSourceGDI;
|
||||
PXLATEOBJ XlateObj = NULL;
|
||||
HPALETTE SourcePalette, DestPalette;
|
||||
|
@ -89,7 +88,6 @@ BOOL STDCALL NtGdiBitBlt(HDC hDCDest,
|
|||
|
||||
SurfDestAlloc = FALSE;
|
||||
SurfSrcAlloc = FALSE;
|
||||
XlateAlloc = FALSE;
|
||||
|
||||
// Determine surfaces to be used in the bitblt
|
||||
SurfDest = (PSURFOBJ)AccessUserObject((ULONG)DCDest->Surface);
|
||||
|
@ -98,22 +96,7 @@ BOOL STDCALL NtGdiBitBlt(HDC hDCDest,
|
|||
SurfGDIDest = (PSURFGDI)AccessInternalObjectFromUserObject(SurfDest);
|
||||
SurfGDISrc = (PSURFGDI)AccessInternalObjectFromUserObject(SurfSrc);
|
||||
|
||||
// Retrieve the logical palette of the destination DC
|
||||
DCLogPal = (PPALOBJ)PALETTE_LockPalette(DCDest->w.hPalette);
|
||||
|
||||
if(DCLogPal)
|
||||
{
|
||||
if(DCLogPal->logicalToSystem)
|
||||
{
|
||||
XlateObj = DCLogPal->logicalToSystem;
|
||||
}
|
||||
PALETTE_UnlockPalette(DCDest->w.hPalette);
|
||||
}
|
||||
|
||||
// If the source and destination formats differ, create an XlateObj [what if we already have one??]
|
||||
if((BitsPerFormat(SurfDest->iBitmapFormat) != BitsPerFormat(SurfSrc->iBitmapFormat)) && (XlateObj == NULL))
|
||||
{
|
||||
if(DCDest->w.hPalette != 0)
|
||||
if (DCDest->w.hPalette != 0)
|
||||
{
|
||||
DestPalette = DCDest->w.hPalette;
|
||||
}
|
||||
|
@ -146,14 +129,12 @@ BOOL STDCALL NtGdiBitBlt(HDC hDCDest,
|
|||
}
|
||||
|
||||
XlateObj = (PXLATEOBJ)IntEngCreateXlate(DestMode, SourceMode, DestPalette, SourcePalette);
|
||||
XlateAlloc = TRUE;
|
||||
}
|
||||
|
||||
// Perform the bitblt operation
|
||||
|
||||
Status = IntEngBitBlt(SurfDest, SurfSrc, NULL, DCDest->CombinedClip, XlateObj, &DestRect, &SourcePoint, NULL, NULL, NULL, ROP);
|
||||
|
||||
if (XlateAlloc) EngDeleteXlate(XlateObj);
|
||||
EngDeleteXlate(XlateObj);
|
||||
if (SurfDestAlloc) ExFreePool(SurfDest);
|
||||
if (SurfSrcAlloc) ExFreePool(SurfSrc);
|
||||
|
||||
|
@ -530,7 +511,7 @@ BOOL STDCALL NtGdiSetPixelV(HDC hDC,
|
|||
}
|
||||
bm = bmp->bitmap;
|
||||
//FIXME: set the actual pixel value
|
||||
BITMAPOBJ_UnlockBitmap (bmp);
|
||||
BITMAPOBJ_UnlockBitmap (dc->w.hBitmap);
|
||||
DC_UnlockDc (hDC);
|
||||
return(TRUE);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: cliprgn.c,v 1.22 2003/08/29 09:29:11 gvg Exp $ */
|
||||
/* $Id: cliprgn.c,v 1.23 2003/08/31 07:56:24 gvg Exp $ */
|
||||
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
@ -231,12 +231,14 @@ int STDCALL NtGdiSelectClipRgn(HDC hDC,
|
|||
Copy = NtGdiCreateRectRgn(0, 0, 0, 0);
|
||||
if (NULL == Copy)
|
||||
{
|
||||
DC_UnlockDc(hDC);
|
||||
return ERROR;
|
||||
}
|
||||
Type = NtGdiCombineRgn(Copy, hRgn, 0, RGN_COPY);
|
||||
if (ERROR == Type)
|
||||
{
|
||||
NtGdiDeleteObject(Copy);
|
||||
DC_UnlockDc(hDC);
|
||||
return ERROR;
|
||||
}
|
||||
NtGdiOffsetRgn(Copy, dc->w.DCOrgX, dc->w.DCOrgY);
|
||||
|
@ -252,6 +254,7 @@ int STDCALL NtGdiSelectClipRgn(HDC hDC,
|
|||
}
|
||||
dc->w.hClipRgn = Copy;
|
||||
CLIPPING_UpdateGCRegion(dc);
|
||||
DC_UnlockDc(hDC);
|
||||
|
||||
return ERROR;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: dc.c,v 1.77 2003/08/29 12:28:24 gvg Exp $
|
||||
/* $Id: dc.c,v 1.78 2003/08/31 07:56:24 gvg Exp $
|
||||
*
|
||||
* DC.C - Device context functions
|
||||
*
|
||||
|
@ -113,9 +113,6 @@ INT STDCALL func_name( HDC hdc, INT mode ) \
|
|||
|
||||
// --------------------------------------------------------- File Statics
|
||||
|
||||
static VOID FASTCALL
|
||||
NtGdiSetDCState16(HDC hDC, HDC hDCSave);
|
||||
|
||||
// ----------------------------------------------------- Public Functions
|
||||
|
||||
BOOL STDCALL
|
||||
|
@ -131,6 +128,7 @@ NtGdiCreateCompatableDC(HDC hDC)
|
|||
HBITMAP hBitmap;
|
||||
HDC hNewDC;
|
||||
HRGN hVisRgn;
|
||||
BITMAPOBJ *pb;
|
||||
|
||||
OrigDC = DC_LockDc(hDC);
|
||||
if (OrigDC == NULL)
|
||||
|
@ -155,6 +153,11 @@ NtGdiCreateCompatableDC(HDC hDC)
|
|||
/* FIXME: Should this DC request its own PDEV? */
|
||||
if(OrigDC == NULL)
|
||||
{
|
||||
NewDC->PDev = PrimarySurface.PDev;
|
||||
memcpy(NewDC->FillPatternSurfaces, PrimarySurface.FillPatterns,
|
||||
sizeof(NewDC->FillPatternSurfaces));
|
||||
NewDC->GDIInfo = &PrimarySurface.GDIInfo;
|
||||
NewDC->DevInfo = &PrimarySurface.DevInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -197,9 +200,15 @@ NtGdiCreateCompatableDC(HDC hDC)
|
|||
NewDC->w.bitsPerPixel = 1;
|
||||
NewDC->w.hBitmap = hBitmap;
|
||||
NewDC->w.hFirstBitmap = hBitmap;
|
||||
NewDC->Surface = BitmapToSurf(BITMAPOBJ_LockBitmap(hBitmap));
|
||||
pb = BITMAPOBJ_LockBitmap(hBitmap);
|
||||
NewDC->Surface = BitmapToSurf(pb);
|
||||
BITMAPOBJ_UnlockBitmap(hBitmap);
|
||||
|
||||
if(OrigDC != NULL)
|
||||
if(OrigDC == NULL)
|
||||
{
|
||||
NewDC->w.hPalette = NewDC->DevInfo->hpalDefault;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewDC->w.hPalette = OrigDC->w.hPalette;
|
||||
NewDC->w.textColor = OrigDC->w.textColor;
|
||||
|
@ -560,10 +569,6 @@ NtGdiDeleteDC(HDC DCHandle)
|
|||
NtGdiSelectObject (DCHandle, STOCK_WHITE_BRUSH);
|
||||
NtGdiSelectObject (DCHandle, STOCK_SYSTEM_FONT);
|
||||
DC_LockDC (DCHandle); NtGdiSelectObject does not recognize stock objects yet */
|
||||
if ( DCToDelete->w.hBitmap != NULL )
|
||||
{
|
||||
BITMAPOBJ_UnlockBitmap(DCToDelete->w.hBitmap);
|
||||
}
|
||||
if (DCToDelete->w.flags & DC_MEMORY)
|
||||
{
|
||||
EngDeleteSurface (DCToDelete->Surface);
|
||||
|
@ -649,8 +654,23 @@ NtGdiGetDCOrgEx(HDC hDC, LPPOINT Point)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
HDC STDCALL
|
||||
NtGdiGetDCState16(HDC hDC)
|
||||
COLORREF STDCALL
|
||||
NtGdiSetBkColor(HDC hDC, COLORREF color)
|
||||
{
|
||||
COLORREF oldColor;
|
||||
PDC dc = DC_LockDc(hDC);
|
||||
|
||||
if ( !dc )
|
||||
return 0x80000000;
|
||||
|
||||
oldColor = dc->w.backgroundColor;
|
||||
dc->w.backgroundColor = color;
|
||||
DC_UnlockDc ( hDC );
|
||||
return oldColor;
|
||||
}
|
||||
|
||||
static HDC STDCALL
|
||||
NtGdiGetDCState(HDC hDC)
|
||||
{
|
||||
PDC newdc, dc;
|
||||
HDC hnewdc;
|
||||
|
@ -744,9 +764,120 @@ NtGdiGetDCState16(HDC hDC)
|
|||
newdc->w.hClipRgn = 0;
|
||||
}
|
||||
DC_UnlockDc( hnewdc );
|
||||
DC_UnlockDc( hDC );
|
||||
return hnewdc;
|
||||
}
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
FASTCALL
|
||||
NtGdiSetDCState ( HDC hDC, HDC hDCSave )
|
||||
{
|
||||
PDC dc, dcs;
|
||||
|
||||
dc = DC_LockDc ( hDC );
|
||||
if ( dc )
|
||||
{
|
||||
dcs = DC_LockDc ( hDCSave );
|
||||
if ( dcs )
|
||||
{
|
||||
if ( dcs->w.flags & DC_SAVED )
|
||||
{
|
||||
dc->w.flags = dcs->w.flags & ~DC_SAVED;
|
||||
|
||||
dc->w.hFirstBitmap = dcs->w.hFirstBitmap;
|
||||
|
||||
#if 0
|
||||
dc->w.hDevice = dcs->w.hDevice;
|
||||
#endif
|
||||
|
||||
dc->w.totalExtent = dcs->w.totalExtent;
|
||||
dc->w.ROPmode = dcs->w.ROPmode;
|
||||
dc->w.polyFillMode = dcs->w.polyFillMode;
|
||||
dc->w.stretchBltMode = dcs->w.stretchBltMode;
|
||||
dc->w.relAbsMode = dcs->w.relAbsMode;
|
||||
dc->w.backgroundMode = dcs->w.backgroundMode;
|
||||
dc->w.backgroundColor = dcs->w.backgroundColor;
|
||||
dc->w.textColor = dcs->w.textColor;
|
||||
dc->w.brushOrgX = dcs->w.brushOrgX;
|
||||
dc->w.brushOrgY = dcs->w.brushOrgY;
|
||||
dc->w.textAlign = dcs->w.textAlign;
|
||||
dc->w.charExtra = dcs->w.charExtra;
|
||||
dc->w.breakTotalExtra = dcs->w.breakTotalExtra;
|
||||
dc->w.breakCount = dcs->w.breakCount;
|
||||
dc->w.breakExtra = dcs->w.breakExtra;
|
||||
dc->w.breakRem = dcs->w.breakRem;
|
||||
dc->w.MapMode = dcs->w.MapMode;
|
||||
dc->w.GraphicsMode = dcs->w.GraphicsMode;
|
||||
#if 0
|
||||
/* Apparently, the DC origin is not changed by [GS]etDCState */
|
||||
dc->w.DCOrgX = dcs->w.DCOrgX;
|
||||
dc->w.DCOrgY = dcs->w.DCOrgY;
|
||||
#endif
|
||||
dc->w.CursPosX = dcs->w.CursPosX;
|
||||
dc->w.CursPosY = dcs->w.CursPosY;
|
||||
dc->w.ArcDirection = dcs->w.ArcDirection;
|
||||
|
||||
#if 0
|
||||
dc->w.xformWorld2Wnd = dcs->w.xformWorld2Wnd;
|
||||
dc->w.xformWorld2Vport = dcs->w.xformWorld2Vport;
|
||||
dc->w.xformVport2World = dcs->w.xformVport2World;
|
||||
dc->w.vport2WorldValid = dcs->w.vport2WorldValid;
|
||||
#endif
|
||||
|
||||
dc->wndOrgX = dcs->wndOrgX;
|
||||
dc->wndOrgY = dcs->wndOrgY;
|
||||
dc->wndExtX = dcs->wndExtX;
|
||||
dc->wndExtY = dcs->wndExtY;
|
||||
dc->vportOrgX = dcs->vportOrgX;
|
||||
dc->vportOrgY = dcs->vportOrgY;
|
||||
dc->vportExtX = dcs->vportExtX;
|
||||
dc->vportExtY = dcs->vportExtY;
|
||||
|
||||
if (!(dc->w.flags & DC_MEMORY))
|
||||
{
|
||||
dc->w.bitsPerPixel = dcs->w.bitsPerPixel;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (dcs->w.hClipRgn)
|
||||
{
|
||||
if (!dc->w.hClipRgn)
|
||||
{
|
||||
dc->w.hClipRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
|
||||
}
|
||||
NtGdiCombineRgn( dc->w.hClipRgn, dcs->w.hClipRgn, 0, RGN_COPY );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dc->w.hClipRgn)
|
||||
{
|
||||
NtGdiDeleteObject( dc->w.hClipRgn );
|
||||
}
|
||||
|
||||
dc->w.hClipRgn = 0;
|
||||
}
|
||||
CLIPPING_UpdateGCRegion( dc );
|
||||
#endif
|
||||
|
||||
NtGdiSelectObject( hDC, dcs->w.hBitmap );
|
||||
NtGdiSelectObject( hDC, dcs->w.hBrush );
|
||||
NtGdiSelectObject( hDC, dcs->w.hFont );
|
||||
NtGdiSelectObject( hDC, dcs->w.hPen );
|
||||
NtGdiSetBkColor( hDC, dcs->w.backgroundColor);
|
||||
NtGdiSetTextColor( hDC, dcs->w.textColor);
|
||||
|
||||
#if 0
|
||||
GDISelectPalette16( hDC, dcs->w.hPalette, FALSE );
|
||||
#endif
|
||||
}
|
||||
|
||||
DC_UnlockDc ( hDCSave );
|
||||
}
|
||||
DC_UnlockDc ( hDC );
|
||||
}
|
||||
}
|
||||
|
||||
INT STDCALL
|
||||
NtGdiGetDeviceCaps(HDC hDC,
|
||||
INT Index)
|
||||
|
@ -1175,7 +1306,9 @@ NtGdiRestoreDC(HDC hDC, INT SaveLevel)
|
|||
DC_SetNextDC (dcs, DC_GetNextDC (dcs));
|
||||
if (--dc->saveLevel < SaveLevel)
|
||||
{
|
||||
NtGdiSetDCState16 (hDC, hdcs);
|
||||
DC_UnlockDc( hDC );
|
||||
DC_UnlockDc( hdcs );
|
||||
NtGdiSetDCState(hDC, hdcs);
|
||||
#if 0
|
||||
if (!PATH_AssignGdiPath( &dc->w.path, &dcs->w.path ))
|
||||
{
|
||||
|
@ -1184,8 +1317,16 @@ NtGdiRestoreDC(HDC hDC, INT SaveLevel)
|
|||
success = FALSE;
|
||||
}
|
||||
#endif
|
||||
dc = DC_LockDc(hDC);
|
||||
if(!dc)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DC_UnlockDc( hdcs );
|
||||
}
|
||||
NtGdiDeleteDC (hdcs);
|
||||
}
|
||||
DC_UnlockDc( hDC );
|
||||
|
@ -1199,17 +1340,22 @@ NtGdiSaveDC(HDC hDC)
|
|||
PDC dc, dcs;
|
||||
INT ret;
|
||||
|
||||
dc = DC_LockDc (hDC);
|
||||
if (dc == NULL)
|
||||
if (!(hdcs = NtGdiGetDCState(hDC)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(hdcs = NtGdiGetDCState16 (hDC)))
|
||||
dcs = DC_LockDc (hdcs);
|
||||
if (dcs == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
dcs = DC_LockDc (hdcs);
|
||||
dc = DC_LockDc (hDC);
|
||||
if (dc == NULL)
|
||||
{
|
||||
DC_UnlockDc(dc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Copy path. The reason why path saving / restoring is in SaveDC/
|
||||
|
@ -1320,7 +1466,6 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj)
|
|||
|
||||
/* Release the old bitmap, lock the new one and convert it to a SURF */
|
||||
EngDeleteSurface(dc->Surface);
|
||||
BITMAPOBJ_UnlockBitmap(objOrg);
|
||||
dc->w.hBitmap = hGDIObj;
|
||||
pb = BITMAPOBJ_LockBitmap(hGDIObj);
|
||||
ASSERT(pb);
|
||||
|
@ -1366,6 +1511,7 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj)
|
|||
hVisRgn = NtGdiCreateRectRgn ( 0, 0, pb->size.cx, pb->size.cy );
|
||||
NtGdiSelectVisRgn ( hDC, hVisRgn );
|
||||
NtGdiDeleteObject ( hVisRgn );
|
||||
BITMAPOBJ_UnlockBitmap(hGDIObj);
|
||||
|
||||
return objOrg;
|
||||
|
||||
|
@ -1388,131 +1534,6 @@ DC_SET_MODE( NtGdiSetPolyFillMode, w.polyFillMode, ALTERNATE, WINDING )
|
|||
DC_SET_MODE( NtGdiSetROP2, w.ROPmode, R2_BLACK, R2_WHITE )
|
||||
DC_SET_MODE( NtGdiSetStretchBltMode, w.stretchBltMode, BLACKONWHITE, HALFTONE )
|
||||
|
||||
COLORREF STDCALL
|
||||
NtGdiSetBkColor(HDC hDC, COLORREF color)
|
||||
{
|
||||
COLORREF oldColor;
|
||||
PDC dc = DC_LockDc(hDC);
|
||||
|
||||
if ( !dc )
|
||||
return 0x80000000;
|
||||
|
||||
oldColor = dc->w.backgroundColor;
|
||||
dc->w.backgroundColor = color;
|
||||
DC_UnlockDc ( hDC );
|
||||
return oldColor;
|
||||
}
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
FASTCALL
|
||||
NtGdiSetDCState16 ( HDC hDC, HDC hDCSave )
|
||||
{
|
||||
PDC dc, dcs;
|
||||
|
||||
dc = DC_LockDc ( hDC );
|
||||
if ( dc )
|
||||
{
|
||||
dcs = DC_LockDc ( hDCSave );
|
||||
if ( dcs )
|
||||
{
|
||||
if ( dcs->w.flags & DC_SAVED )
|
||||
{
|
||||
dc->w.flags = dcs->w.flags & ~DC_SAVED;
|
||||
|
||||
dc->w.hFirstBitmap = dcs->w.hFirstBitmap;
|
||||
|
||||
#if 0
|
||||
dc->w.hDevice = dcs->w.hDevice;
|
||||
#endif
|
||||
|
||||
dc->w.totalExtent = dcs->w.totalExtent;
|
||||
dc->w.ROPmode = dcs->w.ROPmode;
|
||||
dc->w.polyFillMode = dcs->w.polyFillMode;
|
||||
dc->w.stretchBltMode = dcs->w.stretchBltMode;
|
||||
dc->w.relAbsMode = dcs->w.relAbsMode;
|
||||
dc->w.backgroundMode = dcs->w.backgroundMode;
|
||||
dc->w.backgroundColor = dcs->w.backgroundColor;
|
||||
dc->w.textColor = dcs->w.textColor;
|
||||
dc->w.brushOrgX = dcs->w.brushOrgX;
|
||||
dc->w.brushOrgY = dcs->w.brushOrgY;
|
||||
dc->w.textAlign = dcs->w.textAlign;
|
||||
dc->w.charExtra = dcs->w.charExtra;
|
||||
dc->w.breakTotalExtra = dcs->w.breakTotalExtra;
|
||||
dc->w.breakCount = dcs->w.breakCount;
|
||||
dc->w.breakExtra = dcs->w.breakExtra;
|
||||
dc->w.breakRem = dcs->w.breakRem;
|
||||
dc->w.MapMode = dcs->w.MapMode;
|
||||
dc->w.GraphicsMode = dcs->w.GraphicsMode;
|
||||
#if 0
|
||||
/* Apparently, the DC origin is not changed by [GS]etDCState */
|
||||
dc->w.DCOrgX = dcs->w.DCOrgX;
|
||||
dc->w.DCOrgY = dcs->w.DCOrgY;
|
||||
#endif
|
||||
dc->w.CursPosX = dcs->w.CursPosX;
|
||||
dc->w.CursPosY = dcs->w.CursPosY;
|
||||
dc->w.ArcDirection = dcs->w.ArcDirection;
|
||||
|
||||
#if 0
|
||||
dc->w.xformWorld2Wnd = dcs->w.xformWorld2Wnd;
|
||||
dc->w.xformWorld2Vport = dcs->w.xformWorld2Vport;
|
||||
dc->w.xformVport2World = dcs->w.xformVport2World;
|
||||
dc->w.vport2WorldValid = dcs->w.vport2WorldValid;
|
||||
#endif
|
||||
|
||||
dc->wndOrgX = dcs->wndOrgX;
|
||||
dc->wndOrgY = dcs->wndOrgY;
|
||||
dc->wndExtX = dcs->wndExtX;
|
||||
dc->wndExtY = dcs->wndExtY;
|
||||
dc->vportOrgX = dcs->vportOrgX;
|
||||
dc->vportOrgY = dcs->vportOrgY;
|
||||
dc->vportExtX = dcs->vportExtX;
|
||||
dc->vportExtY = dcs->vportExtY;
|
||||
|
||||
if (!(dc->w.flags & DC_MEMORY))
|
||||
{
|
||||
dc->w.bitsPerPixel = dcs->w.bitsPerPixel;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (dcs->w.hClipRgn)
|
||||
{
|
||||
if (!dc->w.hClipRgn)
|
||||
{
|
||||
dc->w.hClipRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
|
||||
}
|
||||
NtGdiCombineRgn( dc->w.hClipRgn, dcs->w.hClipRgn, 0, RGN_COPY );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dc->w.hClipRgn)
|
||||
{
|
||||
NtGdiDeleteObject( dc->w.hClipRgn );
|
||||
}
|
||||
|
||||
dc->w.hClipRgn = 0;
|
||||
}
|
||||
CLIPPING_UpdateGCRegion( dc );
|
||||
#endif
|
||||
|
||||
NtGdiSelectObject( hDC, dcs->w.hBitmap );
|
||||
NtGdiSelectObject( hDC, dcs->w.hBrush );
|
||||
NtGdiSelectObject( hDC, dcs->w.hFont );
|
||||
NtGdiSelectObject( hDC, dcs->w.hPen );
|
||||
NtGdiSetBkColor( hDC, dcs->w.backgroundColor);
|
||||
NtGdiSetTextColor( hDC, dcs->w.textColor);
|
||||
|
||||
#if 0
|
||||
GDISelectPalette16( hDC, dcs->w.hPalette, FALSE );
|
||||
#endif
|
||||
}
|
||||
|
||||
DC_UnlockDc ( hDCSave );
|
||||
}
|
||||
DC_UnlockDc ( hDC );
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------- Private Interface
|
||||
|
||||
HDC FASTCALL
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: dib.c,v 1.31 2003/08/28 12:35:59 gvg Exp $
|
||||
* $Id: dib.c,v 1.32 2003/08/31 07:56:24 gvg Exp $
|
||||
*
|
||||
* ReactOS W32 Subsystem
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
|
||||
|
@ -541,18 +541,14 @@ HBITMAP STDCALL NtGdiCreateDIBitmap(HDC hdc, const BITMAPINFOHEADER *header,
|
|||
|
||||
// Now create the bitmap
|
||||
|
||||
if(fColor)
|
||||
{
|
||||
// If we are using indexed colors, then we need to create a bitmap that is compatible with the palette
|
||||
if(coloruse == DIB_PAL_COLORS)
|
||||
if (init == CBM_INIT)
|
||||
{
|
||||
handle = NtGdiCreateCompatibleBitmap(hdc, width, height);
|
||||
}
|
||||
else if(coloruse == DIB_RGB_COLORS) {
|
||||
handle = NtGdiCreateBitmap(width, height, 1, 24, NULL);
|
||||
else
|
||||
{
|
||||
handle = NtGdiCreateBitmap(width, height, 1, bpp, NULL);
|
||||
}
|
||||
}
|
||||
else handle = NtGdiCreateBitmap(width, height, 1, 1, NULL);
|
||||
|
||||
if (!handle) return 0;
|
||||
|
||||
|
@ -692,17 +688,20 @@ DIB_CreateDIBSection(
|
|||
if (dib)
|
||||
{
|
||||
res = NtGdiCreateDIBitmap(dc->hSelf, bi, 0, NULL, bmi, usage);
|
||||
if (res)
|
||||
if (! res)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
bmp = BITMAPOBJ_LockBitmap(res);
|
||||
if (bmp)
|
||||
if (NULL == bmp)
|
||||
{
|
||||
NtGdiDeleteObject(bmp);
|
||||
return NULL;
|
||||
}
|
||||
bmp->dib = (DIBSECTION *) dib;
|
||||
/* Install user-mode bits instead of kernel-mode bits */
|
||||
ExFreePool(bmp->bitmap.bmBits);
|
||||
bmp->bitmap.bmBits = bm.bmBits;
|
||||
}
|
||||
}
|
||||
|
||||
/* WINE NOTE: WINE makes use of a colormap, which is a color translation table between the DIB and the X physical
|
||||
device. Obviously, this is left out of the ReactOS implementation. Instead, we call
|
||||
|
@ -931,7 +930,7 @@ BuildDIBPalette (PBITMAPINFO bmi, PINT paletteType)
|
|||
{
|
||||
BYTE bits;
|
||||
ULONG ColorCount;
|
||||
PALETTEENTRY *palEntries;
|
||||
PALETTEENTRY *palEntries = NULL;
|
||||
HPALETTE hPal;
|
||||
|
||||
// Determine Bits Per Pixel
|
||||
|
@ -948,14 +947,10 @@ BuildDIBPalette (PBITMAPINFO bmi, PINT paletteType)
|
|||
}
|
||||
else
|
||||
{
|
||||
*paletteType = PAL_RGB; // Would it be BGR, considering the BGR nature of the DIB color table?
|
||||
*paletteType = PAL_BGR;
|
||||
}
|
||||
|
||||
#ifdef TODO
|
||||
if (bmi->bmiHeader.biClrUsed == 0)
|
||||
#else
|
||||
if (bmi->bmiHeader.biClrUsed == 0 && bmi->bmiHeader.biBitCount <= 8)
|
||||
#endif
|
||||
{
|
||||
ColorCount = 1 << bmi->bmiHeader.biBitCount;
|
||||
}
|
||||
|
@ -964,10 +959,16 @@ BuildDIBPalette (PBITMAPINFO bmi, PINT paletteType)
|
|||
ColorCount = bmi->bmiHeader.biClrUsed;
|
||||
}
|
||||
|
||||
if (PAL_INDEXED == *paletteType)
|
||||
{
|
||||
palEntries = ExAllocatePool(NonPagedPool, sizeof(PALETTEENTRY)*ColorCount);
|
||||
DIBColorTableToPaletteEntries(palEntries, bmi->bmiColors, ColorCount);
|
||||
}
|
||||
hPal = PALETTE_AllocPalette( *paletteType, ColorCount, (ULONG*)palEntries, 0, 0, 0 );
|
||||
if (NULL != palEntries)
|
||||
{
|
||||
ExFreePool(palEntries);
|
||||
}
|
||||
|
||||
return hPal;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: palette.c,v 1.11 2003/08/28 12:35:59 gvg Exp $ */
|
||||
/* $Id: palette.c,v 1.12 2003/08/31 07:56:24 gvg Exp $ */
|
||||
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
@ -33,17 +33,6 @@
|
|||
static int PALETTE_firstFree = 0;
|
||||
static unsigned char PALETTE_freeList[256];
|
||||
|
||||
#ifdef TODO
|
||||
static ColorShifts PALETTE_PRed = {0,0,0};
|
||||
//static ColorShifts PALETTE_LRed = {0,0,0};
|
||||
static ColorShifts PALETTE_PGreen = {0,0,0};
|
||||
//static ColorShifts PALETTE_LGreen = {0,0,0};
|
||||
static ColorShifts PALETTE_PBlue = {0,0,0};
|
||||
//static ColorShifts PALETTE_LBlue = {0,0,0};
|
||||
static int PALETTE_Graymax = 0;
|
||||
static int palette_size;
|
||||
#endif
|
||||
|
||||
int PALETTE_PaletteFlags = 0;
|
||||
PALETTEENTRY *COLOR_sysPal = NULL;
|
||||
int COLOR_gapStart;
|
||||
|
@ -180,63 +169,6 @@ static void FASTCALL PALETTE_FormatSystemPalette(void)
|
|||
PALETTE_freeList[j] = 0;
|
||||
}
|
||||
|
||||
#ifdef TODO
|
||||
/* Ported from WINE 20020804 (graphics\x11drv\palette.c) */
|
||||
static int FASTCALL SysPaletteLookupPixel( COLORREF col, BOOL skipReserved )
|
||||
{
|
||||
int i, best = 0, diff = 0x7fffffff;
|
||||
int r,g,b;
|
||||
|
||||
for( i = 0; i < palette_size && diff ; i++ )
|
||||
{
|
||||
if( !(COLOR_sysPal[i].peFlags & PC_SYS_USED) || (skipReserved && COLOR_sysPal[i].peFlags & PC_SYS_RESERVED) )
|
||||
continue;
|
||||
|
||||
r = COLOR_sysPal[i].peRed - GetRValue(col);
|
||||
g = COLOR_sysPal[i].peGreen - GetGValue(col);
|
||||
b = COLOR_sysPal[i].peBlue - GetBValue(col);
|
||||
|
||||
r = r*r + g*g + b*b;
|
||||
|
||||
if( r < diff ) { best = i; diff = r; }
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/* Ported from WINE 20020804 (graphics\x11drv\palette.c) */
|
||||
/* Make sure this is required - ROS's xlate may make this redundant */
|
||||
UINT WINAPI GetNearestPaletteIndex(
|
||||
HPALETTE hpalette, /* [in] Handle of logical color palette */
|
||||
COLORREF color) /* [in] Color to be matched */
|
||||
{
|
||||
PPALOBJ palObj = (PPALOBJ)AccessUserObject((ULONG)hpalette);
|
||||
UINT index = 0;
|
||||
|
||||
if( palObj )
|
||||
{
|
||||
int i, diff = 0x7fffffff;
|
||||
int r,g,b;
|
||||
PALETTEENTRY* entry = palObj->logpalette->palPalEntry;
|
||||
|
||||
for( i = 0; i < palObj->logpalette->palNumEntries && diff ; i++, entry++)
|
||||
{
|
||||
if (!(entry->peFlags & PC_SYS_USED)) continue;
|
||||
|
||||
r = entry->peRed - GetRValue(color);
|
||||
g = entry->peGreen - GetGValue(color);
|
||||
b = entry->peBlue - GetBValue(color);
|
||||
|
||||
r = r*r + g*g + b*b;
|
||||
|
||||
if( r < diff ) { index = i; diff = r; }
|
||||
}
|
||||
// GDI_ReleaseObj( hpalette );
|
||||
}
|
||||
DPRINT("(%04x,%06lx): returning %d\n", hpalette, color, index );
|
||||
return index;
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID FASTCALL PALETTE_ValidateFlags(PALETTEENTRY* lpPalE, INT size)
|
||||
{
|
||||
int i = 0;
|
||||
|
@ -348,142 +280,4 @@ INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapO
|
|||
return iRemapped;
|
||||
}
|
||||
|
||||
#ifdef TODO
|
||||
/* Return the physical color closest to 'color'. */
|
||||
/* Ported from WINE 20020804 (graphics\x11drv\palette.c) */
|
||||
INT FASTCALL PALETTE_ToPhysical (PDC dc, COLORREF color)
|
||||
{
|
||||
WORD index = 0;
|
||||
HPALETTE hPal = (dc)? dc->w.hPalette: NtGdiGetStockObject(DEFAULT_PALETTE);
|
||||
unsigned char spec_type = color >> 24;
|
||||
PPALOBJ palPtr = (PPALOBJ)AccessUserObject((ULONG)hPal);
|
||||
|
||||
/* palPtr can be NULL when DC is being destroyed */
|
||||
if( !palPtr ) return 0;
|
||||
|
||||
if ( PALETTE_PaletteFlags & PALETTE_FIXED )
|
||||
{
|
||||
/* there is no colormap limitation; we are going to have to compute
|
||||
* the pixel value from the visual information stored earlier
|
||||
*/
|
||||
|
||||
unsigned long red, green, blue;
|
||||
unsigned idx = 0;
|
||||
|
||||
switch(spec_type)
|
||||
{
|
||||
case 1: /* PALETTEINDEX */
|
||||
|
||||
if( (idx = color & 0xffff) >= palPtr->logpalette->palNumEntries)
|
||||
{
|
||||
DPRINT("RGB(%lx) : idx %d is out of bounds, assuming black\n", color, idx);
|
||||
// GDI_ReleaseObj( hPal );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( palPtr->mapping )
|
||||
{
|
||||
int ret = palPtr->mapping[idx];
|
||||
// GDI_ReleaseObj( hPal );
|
||||
return ret;
|
||||
}
|
||||
color = *(COLORREF*)(palPtr->logpalette->palPalEntry + idx);
|
||||
break;
|
||||
|
||||
default:
|
||||
color &= 0xffffff;
|
||||
/* fall through to RGB */
|
||||
|
||||
case 0: /* RGB */
|
||||
if( dc && (dc->w.bitsPerPixel == 1) )
|
||||
{
|
||||
// GDI_ReleaseObj( hPal );
|
||||
return (((color >> 16) & 0xff) +
|
||||
((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? 1 : 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
red = GetRValue(color); green = GetGValue(color); blue = GetBValue(color);
|
||||
|
||||
if (PALETTE_Graymax)
|
||||
{
|
||||
/* grayscale only; return scaled value */
|
||||
// GDI_ReleaseObj( hPal );
|
||||
return ( (red * 30 + green * 59 + blue * 11) * PALETTE_Graymax) / 25500;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* scale each individually and construct the TrueColor pixel value */
|
||||
if (PALETTE_PRed.scale < 8)
|
||||
red = red >> (8-PALETTE_PRed.scale);
|
||||
else if (PALETTE_PRed.scale > 8)
|
||||
red = red << (PALETTE_PRed.scale-8) |
|
||||
red >> (16-PALETTE_PRed.scale);
|
||||
if (PALETTE_PGreen.scale < 8)
|
||||
green = green >> (8-PALETTE_PGreen.scale);
|
||||
else if (PALETTE_PGreen.scale > 8)
|
||||
green = green << (PALETTE_PGreen.scale-8) |
|
||||
green >> (16-PALETTE_PGreen.scale);
|
||||
if (PALETTE_PBlue.scale < 8)
|
||||
blue = blue >> (8-PALETTE_PBlue.scale);
|
||||
else if (PALETTE_PBlue.scale > 8)
|
||||
blue = blue << (PALETTE_PBlue.scale-8) |
|
||||
blue >> (16-PALETTE_PBlue.scale);
|
||||
|
||||
// GDI_ReleaseObj( hPal );
|
||||
return (red << PALETTE_PRed.shift) | (green << PALETTE_PGreen.shift) | (blue << PALETTE_PBlue.shift);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if( !palPtr->mapping )
|
||||
DPRINT("Palette %04x is not realized\n", dc->w.hPalette);
|
||||
|
||||
switch(spec_type) /* we have to peruse DC and system palette */
|
||||
{
|
||||
default:
|
||||
color &= 0xffffff;
|
||||
/* fall through to RGB */
|
||||
|
||||
case 0: /* RGB */
|
||||
if( dc && (dc->w.bitsPerPixel == 1) )
|
||||
{
|
||||
// GDI_ReleaseObj( hPal );
|
||||
return (((color >> 16) & 0xff) +
|
||||
((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? 1 : 0;
|
||||
}
|
||||
|
||||
index = SysPaletteLookupPixel( color, FALSE);
|
||||
|
||||
/* if (PALETTE_PaletteToXPixel) index = PALETTE_PaletteToXPixel[index]; */
|
||||
|
||||
/* DPRINT(palette,"RGB(%lx) -> pixel %i\n", color, index);
|
||||
*/
|
||||
break;
|
||||
case 1: /* PALETTEINDEX */
|
||||
index = color & 0xffff;
|
||||
|
||||
if( index >= palPtr->logpalette->palNumEntries )
|
||||
DbgPrint("RGB(%lx) : index %i is out of bounds\n", color, index);
|
||||
else if( palPtr->mapping ) index = palPtr->mapping[index];
|
||||
|
||||
/* DPRINT(palette,"PALETTEINDEX(%04x) -> pixel %i\n", (WORD)color, index);
|
||||
*/
|
||||
break;
|
||||
case 2: /* PALETTERGB */
|
||||
index = GetNearestPaletteIndex( hPal, color );
|
||||
if (palPtr->mapping) index = palPtr->mapping[index];
|
||||
/* DPRINT(palette,"PALETTERGB(%lx) -> pixel %i\n", color, index);
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// GDI_ReleaseObj( hPal );
|
||||
return index;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue