mirror of
https://github.com/reactos/reactos.git
synced 2024-08-05 02:50:55 +00:00
[WIN32K]
- Cast Colors to RGBQUAD in EngCreateBitmap, since that's what they are. - Copy selected palette of the DC when creating a DIBSection with DIB_PAL_COLORS. - Do not try to get Colors in NtGdiGetDIBitsInternal when bpp == 0, this doesn't make any sense. - Get rid of SURFACE::dsBitfields and SURFACE::biClrUsed. - Use RGB as default palette mod when creating the DIB Palette. svn path=/branches/reactos-yarotows/; revision=48369
This commit is contained in:
parent
b011aff53b
commit
147e52c02c
|
@ -39,8 +39,6 @@ typedef struct _SURFACE
|
||||||
//UINT unk_078;
|
//UINT unk_078;
|
||||||
|
|
||||||
/* reactos specific */
|
/* reactos specific */
|
||||||
DWORD dsBitfields[3]; // hack, should probably use palette instead
|
|
||||||
DWORD biClrUsed;
|
|
||||||
DWORD biClrImportant;
|
DWORD biClrImportant;
|
||||||
} SURFACE, *PSURFACE;
|
} SURFACE, *PSURFACE;
|
||||||
|
|
||||||
|
|
|
@ -1032,11 +1032,11 @@ BITMAP_GetObject(SURFACE *psurf, INT Count, LPVOID buffer)
|
||||||
pds->dsBmih.biSizeImage = psurf->SurfObj.cjBits;
|
pds->dsBmih.biSizeImage = psurf->SurfObj.cjBits;
|
||||||
pds->dsBmih.biXPelsPerMeter = 0;
|
pds->dsBmih.biXPelsPerMeter = 0;
|
||||||
pds->dsBmih.biYPelsPerMeter = 0;
|
pds->dsBmih.biYPelsPerMeter = 0;
|
||||||
pds->dsBmih.biClrUsed = psurf->biClrUsed;
|
pds->dsBmih.biClrUsed = psurf->ppal->NumColors;
|
||||||
pds->dsBmih.biClrImportant = psurf->biClrImportant;
|
pds->dsBmih.biClrImportant = psurf->biClrImportant;
|
||||||
pds->dsBitfields[0] = psurf->dsBitfields[0];
|
pds->dsBitfields[0] = psurf->ppal->RedMask;
|
||||||
pds->dsBitfields[1] = psurf->dsBitfields[1];
|
pds->dsBitfields[1] = psurf->ppal->GreenMask;
|
||||||
pds->dsBitfields[2] = psurf->dsBitfields[2];
|
pds->dsBitfields[2] = psurf->ppal->BlueMask;
|
||||||
pds->dshSection = psurf->hDIBSection;
|
pds->dshSection = psurf->hDIBSection;
|
||||||
pds->dsOffset = psurf->dwOffset;
|
pds->dsOffset = psurf->dwOffset;
|
||||||
|
|
||||||
|
|
|
@ -705,7 +705,6 @@ NtGdiGetDIBitsInternal(
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
get_info:
|
|
||||||
/* Fill in the structure */
|
/* Fill in the structure */
|
||||||
switch(bpp)
|
switch(bpp)
|
||||||
{
|
{
|
||||||
|
@ -755,8 +754,7 @@ get_info:
|
||||||
Info->bmiHeader.biClrImportant = 0;
|
Info->bmiHeader.biClrImportant = 0;
|
||||||
ScanLines = psurf->SurfObj.sizlBitmap.cy;
|
ScanLines = psurf->SurfObj.sizlBitmap.cy;
|
||||||
/* Get Complete info now */
|
/* Get Complete info now */
|
||||||
bpp = Info->bmiHeader.biBitCount ;
|
goto done;
|
||||||
goto get_info;
|
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -916,7 +914,12 @@ get_info:
|
||||||
case 16:
|
case 16:
|
||||||
if (Info->bmiHeader.biCompression == BI_BITFIELDS)
|
if (Info->bmiHeader.biCompression == BI_BITFIELDS)
|
||||||
{
|
{
|
||||||
if (psurf->hSecure) RtlCopyMemory( Info->bmiColors, psurf->dsBitfields, 3 * sizeof(DWORD) );
|
if (psurf->hSecure)
|
||||||
|
{
|
||||||
|
((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask;
|
||||||
|
((PDWORD)Info->bmiColors)[1] = psurf->ppal->GreenMask;
|
||||||
|
((PDWORD)Info->bmiColors)[2] = psurf->ppal->BlueMask;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
((PDWORD)Info->bmiColors)[0] = 0xf800;
|
((PDWORD)Info->bmiColors)[0] = 0xf800;
|
||||||
|
@ -930,7 +933,12 @@ get_info:
|
||||||
case 32:
|
case 32:
|
||||||
if (Info->bmiHeader.biCompression == BI_BITFIELDS)
|
if (Info->bmiHeader.biCompression == BI_BITFIELDS)
|
||||||
{
|
{
|
||||||
if (psurf->hSecure) RtlCopyMemory( Info->bmiColors, psurf->dsBitfields, 3 * sizeof(DWORD) );
|
if (psurf->hSecure)
|
||||||
|
{
|
||||||
|
((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask;
|
||||||
|
((PDWORD)Info->bmiColors)[1] = psurf->ppal->GreenMask;
|
||||||
|
((PDWORD)Info->bmiColors)[2] = psurf->ppal->BlueMask;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
((PDWORD)Info->bmiColors)[0] = 0xff0000;
|
((PDWORD)Info->bmiColors)[0] = 0xff0000;
|
||||||
|
@ -1427,7 +1435,7 @@ DIB_CreateDIBSection(
|
||||||
SURFACE *bmp = NULL;
|
SURFACE *bmp = NULL;
|
||||||
void *mapBits = NULL;
|
void *mapBits = NULL;
|
||||||
HPALETTE hpal ;
|
HPALETTE hpal ;
|
||||||
ULONG palMode = PAL_INDEXED;
|
INT palMode = PAL_INDEXED;
|
||||||
|
|
||||||
// Fill BITMAP32 structure with DIB data
|
// Fill BITMAP32 structure with DIB data
|
||||||
CONST BITMAPINFOHEADER *bi = &bmi->bmiHeader;
|
CONST BITMAPINFOHEADER *bi = &bmi->bmiHeader;
|
||||||
|
@ -1435,10 +1443,7 @@ DIB_CreateDIBSection(
|
||||||
ULONG totalSize;
|
ULONG totalSize;
|
||||||
BITMAP bm;
|
BITMAP bm;
|
||||||
SIZEL Size;
|
SIZEL Size;
|
||||||
CONST RGBQUAD *lpRGB = NULL;
|
|
||||||
HANDLE hSecure;
|
HANDLE hSecure;
|
||||||
DWORD dsBitfields[3] = {0};
|
|
||||||
ULONG ColorCount;
|
|
||||||
|
|
||||||
DPRINT("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
|
DPRINT("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
|
||||||
bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
|
bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
|
||||||
|
@ -1520,55 +1525,28 @@ DIB_CreateDIBSection(
|
||||||
|
|
||||||
if (usage == DIB_PAL_COLORS)
|
if (usage == DIB_PAL_COLORS)
|
||||||
{
|
{
|
||||||
lpRGB = DIB_MapPaletteColors(dc, bmi);
|
PPALETTE pdcPal ;
|
||||||
ColorCount = bi->biClrUsed;
|
pdcPal = PALETTE_LockPalette(dc->dclevel.hpal);
|
||||||
if (ColorCount == 0)
|
if(!pdcPal)
|
||||||
{
|
{
|
||||||
ColorCount = max(1 << bi->biBitCount, 256);
|
DPRINT1("Unable to lock DC palette?!\n");
|
||||||
}
|
goto cleanup;
|
||||||
|
}
|
||||||
|
if(pdcPal->Mode != PAL_INDEXED)
|
||||||
|
{
|
||||||
|
DPRINT1("Not indexed palette selected in the DC?!\n");
|
||||||
|
PALETTE_UnlockPalette(pdcPal);
|
||||||
|
}
|
||||||
|
hpal = PALETTE_AllocPalette(PAL_INDEXED,
|
||||||
|
pdcPal->NumColors,
|
||||||
|
(ULONG*)pdcPal->IndexedColors, 0, 0, 0);
|
||||||
|
PALETTE_UnlockPalette(pdcPal);
|
||||||
}
|
}
|
||||||
else if(bi->biBitCount <= 8)
|
else
|
||||||
{
|
|
||||||
lpRGB = bmi->bmiColors;
|
|
||||||
ColorCount = 1 << bi->biBitCount;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
lpRGB = NULL;
|
hpal = BuildDIBPalette(bmi, &palMode);
|
||||||
ColorCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set dsBitfields values */
|
|
||||||
if (usage == DIB_PAL_COLORS || bi->biBitCount <= 8)
|
|
||||||
{
|
|
||||||
dsBitfields[0] = dsBitfields[1] = dsBitfields[2] = 0;
|
|
||||||
palMode = PAL_INDEXED;
|
|
||||||
}
|
|
||||||
else if (bi->biCompression == BI_RGB)
|
|
||||||
{
|
|
||||||
dsBitfields[0] = dsBitfields[1] = dsBitfields[2] = 0;
|
|
||||||
switch (bi->biBitCount)
|
|
||||||
{
|
|
||||||
case 15:
|
|
||||||
palMode = PAL_RGB16_555;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 16:
|
|
||||||
palMode = PAL_RGB16_565;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 24:
|
|
||||||
case 32:
|
|
||||||
palMode = PAL_RGB;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RtlCopyMemory(dsBitfields, bmi->bmiColors, sizeof(dsBitfields));
|
|
||||||
palMode = PAL_BITFIELDS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create Device Dependent Bitmap and add DIB pointer
|
// Create Device Dependent Bitmap and add DIB pointer
|
||||||
Size.cx = bm.bmWidth;
|
Size.cx = bm.bmWidth;
|
||||||
Size.cy = abs(bm.bmHeight);
|
Size.cy = abs(bm.bmHeight);
|
||||||
|
@ -1600,18 +1578,9 @@ DIB_CreateDIBSection(
|
||||||
bmp->hSecure = hSecure;
|
bmp->hSecure = hSecure;
|
||||||
bmp->dwOffset = offset;
|
bmp->dwOffset = offset;
|
||||||
bmp->flags = API_BITMAP;
|
bmp->flags = API_BITMAP;
|
||||||
bmp->dsBitfields[0] = dsBitfields[0];
|
|
||||||
bmp->dsBitfields[1] = dsBitfields[1];
|
|
||||||
bmp->dsBitfields[2] = dsBitfields[2];
|
|
||||||
bmp->biClrUsed = ColorCount;
|
|
||||||
bmp->biClrImportant = bi->biClrImportant;
|
bmp->biClrImportant = bi->biClrImportant;
|
||||||
|
|
||||||
hpal = PALETTE_AllocPalette(palMode, ColorCount, (ULONG*)lpRGB,
|
bmp->ppal = PALETTE_ShareLockPalette(hpal);
|
||||||
dsBitfields[0],
|
|
||||||
dsBitfields[1],
|
|
||||||
dsBitfields[2]);
|
|
||||||
|
|
||||||
bmp->ppal = PALETTE_ShareLockPalette(hpal);
|
|
||||||
/* Lazy delete hpal, it will be freed at surface release */
|
/* Lazy delete hpal, it will be freed at surface release */
|
||||||
GreDeleteObject(hpal);
|
GreDeleteObject(hpal);
|
||||||
|
|
||||||
|
@ -1643,11 +1612,6 @@ cleanup:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpRGB != bmi->bmiColors && lpRGB)
|
|
||||||
{
|
|
||||||
ExFreePoolWithTag((PVOID)lpRGB, TAG_COLORMAP);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bmp)
|
if (bmp)
|
||||||
{
|
{
|
||||||
SURFACE_UnlockSurface(bmp);
|
SURFACE_UnlockSurface(bmp);
|
||||||
|
@ -1853,7 +1817,7 @@ BuildDIBPalette(CONST BITMAPINFO *bmi, PINT paletteType)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*paletteType = PAL_BGR;
|
*paletteType = PAL_RGB;
|
||||||
RedMask = 0xff0000;
|
RedMask = 0xff0000;
|
||||||
GreenMask = 0x00ff00;
|
GreenMask = 0x00ff00;
|
||||||
BlueMask = 0x0000ff;
|
BlueMask = 0x0000ff;
|
||||||
|
@ -1874,7 +1838,7 @@ BuildDIBPalette(CONST BITMAPINFO *bmi, PINT paletteType)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hPal = PALETTE_AllocPalette(*paletteType, ColorCount,
|
hPal = PALETTE_AllocPalette(*paletteType, 0,
|
||||||
NULL,
|
NULL,
|
||||||
RedMask, GreenMask, BlueMask);
|
RedMask, GreenMask, BlueMask);
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,7 +392,15 @@ EngCreatePalette(
|
||||||
{
|
{
|
||||||
HPALETTE Palette;
|
HPALETTE Palette;
|
||||||
|
|
||||||
Palette = PALETTE_AllocPalette(Mode, NumColors, Colors, Red, Green, Blue);
|
/* Low order three bytes are RGB -> RGBQUAD */
|
||||||
|
if(Mode == PAL_INDEXED)
|
||||||
|
{
|
||||||
|
Palette = PALETTE_AllocPaletteIndexedRGB(NumColors, (RGBQUAD*)Colors);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Palette = PALETTE_AllocPalette(Mode, NumColors, Colors, Red, Green, Blue);
|
||||||
|
}
|
||||||
if (Palette != NULL)
|
if (Palette != NULL)
|
||||||
{
|
{
|
||||||
GDIOBJ_SetOwnership(Palette, NULL);
|
GDIOBJ_SetOwnership(Palette, NULL);
|
||||||
|
|
Loading…
Reference in a new issue