mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +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
4 changed files with 48 additions and 78 deletions
|
@ -39,8 +39,6 @@ typedef struct _SURFACE
|
|||
//UINT unk_078;
|
||||
|
||||
/* reactos specific */
|
||||
DWORD dsBitfields[3]; // hack, should probably use palette instead
|
||||
DWORD biClrUsed;
|
||||
DWORD biClrImportant;
|
||||
} SURFACE, *PSURFACE;
|
||||
|
||||
|
|
|
@ -1032,11 +1032,11 @@ BITMAP_GetObject(SURFACE *psurf, INT Count, LPVOID buffer)
|
|||
pds->dsBmih.biSizeImage = psurf->SurfObj.cjBits;
|
||||
pds->dsBmih.biXPelsPerMeter = 0;
|
||||
pds->dsBmih.biYPelsPerMeter = 0;
|
||||
pds->dsBmih.biClrUsed = psurf->biClrUsed;
|
||||
pds->dsBmih.biClrUsed = psurf->ppal->NumColors;
|
||||
pds->dsBmih.biClrImportant = psurf->biClrImportant;
|
||||
pds->dsBitfields[0] = psurf->dsBitfields[0];
|
||||
pds->dsBitfields[1] = psurf->dsBitfields[1];
|
||||
pds->dsBitfields[2] = psurf->dsBitfields[2];
|
||||
pds->dsBitfields[0] = psurf->ppal->RedMask;
|
||||
pds->dsBitfields[1] = psurf->ppal->GreenMask;
|
||||
pds->dsBitfields[2] = psurf->ppal->BlueMask;
|
||||
pds->dshSection = psurf->hDIBSection;
|
||||
pds->dsOffset = psurf->dwOffset;
|
||||
|
||||
|
|
|
@ -705,7 +705,6 @@ NtGdiGetDIBitsInternal(
|
|||
goto done;
|
||||
}
|
||||
|
||||
get_info:
|
||||
/* Fill in the structure */
|
||||
switch(bpp)
|
||||
{
|
||||
|
@ -755,8 +754,7 @@ get_info:
|
|||
Info->bmiHeader.biClrImportant = 0;
|
||||
ScanLines = psurf->SurfObj.sizlBitmap.cy;
|
||||
/* Get Complete info now */
|
||||
bpp = Info->bmiHeader.biBitCount ;
|
||||
goto get_info;
|
||||
goto done;
|
||||
|
||||
case 1:
|
||||
case 4:
|
||||
|
@ -916,7 +914,12 @@ get_info:
|
|||
case 16:
|
||||
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
|
||||
{
|
||||
((PDWORD)Info->bmiColors)[0] = 0xf800;
|
||||
|
@ -930,7 +933,12 @@ get_info:
|
|||
case 32:
|
||||
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
|
||||
{
|
||||
((PDWORD)Info->bmiColors)[0] = 0xff0000;
|
||||
|
@ -1427,7 +1435,7 @@ DIB_CreateDIBSection(
|
|||
SURFACE *bmp = NULL;
|
||||
void *mapBits = NULL;
|
||||
HPALETTE hpal ;
|
||||
ULONG palMode = PAL_INDEXED;
|
||||
INT palMode = PAL_INDEXED;
|
||||
|
||||
// Fill BITMAP32 structure with DIB data
|
||||
CONST BITMAPINFOHEADER *bi = &bmi->bmiHeader;
|
||||
|
@ -1435,10 +1443,7 @@ DIB_CreateDIBSection(
|
|||
ULONG totalSize;
|
||||
BITMAP bm;
|
||||
SIZEL Size;
|
||||
CONST RGBQUAD *lpRGB = NULL;
|
||||
HANDLE hSecure;
|
||||
DWORD dsBitfields[3] = {0};
|
||||
ULONG ColorCount;
|
||||
|
||||
DPRINT("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
|
||||
bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
|
||||
|
@ -1520,55 +1525,28 @@ DIB_CreateDIBSection(
|
|||
|
||||
if (usage == DIB_PAL_COLORS)
|
||||
{
|
||||
lpRGB = DIB_MapPaletteColors(dc, bmi);
|
||||
ColorCount = bi->biClrUsed;
|
||||
if (ColorCount == 0)
|
||||
{
|
||||
ColorCount = max(1 << bi->biBitCount, 256);
|
||||
}
|
||||
PPALETTE pdcPal ;
|
||||
pdcPal = PALETTE_LockPalette(dc->dclevel.hpal);
|
||||
if(!pdcPal)
|
||||
{
|
||||
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)
|
||||
{
|
||||
lpRGB = bmi->bmiColors;
|
||||
ColorCount = 1 << bi->biBitCount;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
lpRGB = NULL;
|
||||
ColorCount = 0;
|
||||
hpal = BuildDIBPalette(bmi, &palMode);
|
||||
}
|
||||
|
||||
/* 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
|
||||
Size.cx = bm.bmWidth;
|
||||
Size.cy = abs(bm.bmHeight);
|
||||
|
@ -1600,18 +1578,9 @@ DIB_CreateDIBSection(
|
|||
bmp->hSecure = hSecure;
|
||||
bmp->dwOffset = offset;
|
||||
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;
|
||||
|
||||
hpal = PALETTE_AllocPalette(palMode, ColorCount, (ULONG*)lpRGB,
|
||||
dsBitfields[0],
|
||||
dsBitfields[1],
|
||||
dsBitfields[2]);
|
||||
|
||||
bmp->ppal = PALETTE_ShareLockPalette(hpal);
|
||||
bmp->ppal = PALETTE_ShareLockPalette(hpal);
|
||||
/* Lazy delete hpal, it will be freed at surface release */
|
||||
GreDeleteObject(hpal);
|
||||
|
||||
|
@ -1643,11 +1612,6 @@ cleanup:
|
|||
}
|
||||
}
|
||||
|
||||
if (lpRGB != bmi->bmiColors && lpRGB)
|
||||
{
|
||||
ExFreePoolWithTag((PVOID)lpRGB, TAG_COLORMAP);
|
||||
}
|
||||
|
||||
if (bmp)
|
||||
{
|
||||
SURFACE_UnlockSurface(bmp);
|
||||
|
@ -1853,7 +1817,7 @@ BuildDIBPalette(CONST BITMAPINFO *bmi, PINT paletteType)
|
|||
}
|
||||
else
|
||||
{
|
||||
*paletteType = PAL_BGR;
|
||||
*paletteType = PAL_RGB;
|
||||
RedMask = 0xff0000;
|
||||
GreenMask = 0x00ff00;
|
||||
BlueMask = 0x0000ff;
|
||||
|
@ -1874,7 +1838,7 @@ BuildDIBPalette(CONST BITMAPINFO *bmi, PINT paletteType)
|
|||
}
|
||||
else
|
||||
{
|
||||
hPal = PALETTE_AllocPalette(*paletteType, ColorCount,
|
||||
hPal = PALETTE_AllocPalette(*paletteType, 0,
|
||||
NULL,
|
||||
RedMask, GreenMask, BlueMask);
|
||||
}
|
||||
|
|
|
@ -392,7 +392,15 @@ EngCreatePalette(
|
|||
{
|
||||
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)
|
||||
{
|
||||
GDIOBJ_SetOwnership(Palette, NULL);
|
||||
|
|
Loading…
Reference in a new issue