- when converting from a DDB to a DIB, the palette should be the same in the resulting DIB as the original DDB. This fixes the colour issue we had in the taskbar icons. (there's still a bit position problem as highlighted in the 1-4 bitmaps)

- Reformat the NtGdiGetDIBitsInternal code to a more readable state.

*note, this function needs a considerable work.

svn path=/trunk/; revision=29093
This commit is contained in:
Ged Murphy 2007-09-18 15:24:34 +00:00
parent 90c3978be9
commit a98103c630

View file

@ -377,9 +377,9 @@ NtGdiGetDIBitsInternal(HDC hDC,
DC_UnlockDc(Dc);
return 0;
}
hSourcePalette = Dc->w.hPalette;
/* FIXME: This is incorrect. hDestPalette should be something other. */
hDestPalette = Dc->DevInfo->hpalDefault;
hDestPalette = Dc->w.hPalette; // unsure of this (Ged)
DC_UnlockDc(Dc);
/* Get pointer to the source bitmap object. */
@ -400,6 +400,7 @@ NtGdiGetDIBitsInternal(HDC hDC,
coreheader->bcBitCount = BitsPerFormat(BitmapObj->SurfObj.iBitmapFormat);
coreheader->bcHeight = BitmapObj->SurfObj.sizlBitmap.cy;
if (BitmapObj->SurfObj.lDelta > 0)
coreheader->bcHeight = -coreheader->bcHeight;
@ -419,8 +420,12 @@ NtGdiGetDIBitsInternal(HDC hDC,
{
switch (BitmapObj->SurfObj.iBitmapFormat)
{
case BMF_1BPP: case BMF_4BPP: case BMF_8BPP:
case BMF_16BPP: case BMF_24BPP: case BMF_32BPP:
case BMF_1BPP:
case BMF_4BPP:
case BMF_8BPP:
case BMF_16BPP:
case BMF_24BPP:
case BMF_32BPP:
Info->bmiHeader.biCompression = BI_RGB;
break;
case BMF_4RLE:
@ -436,10 +441,11 @@ NtGdiGetDIBitsInternal(HDC hDC,
Info->bmiHeader.biCompression = BI_PNG;
break;
}
Info->bmiHeader.biSizeImage = BitmapObj->SurfObj.cjBits;
Info->bmiHeader.biXPelsPerMeter = 0; /* FIXME */
Info->bmiHeader.biYPelsPerMeter = 0; /* FIXME */
Info->bmiHeader.biClrUsed =
Info->bmiHeader.biClrUsed = 0;
Info->bmiHeader.biClrImportant = 1 << Info->bmiHeader.biBitCount; /* FIXME */
Result = BitmapObj->SurfObj.sizlBitmap.cy;
}
@ -458,16 +464,6 @@ NtGdiGetDIBitsInternal(HDC hDC,
DestSize.cy = ScanLines;
DestBitmap = NULL;
if (Info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER))
{
DestBitmap = EngCreateBitmap(DestSize,
/* DIB_GetDIBWidthBytes(DestSize.cx, Info->bmiHeader.biBitCount), */
DestSize.cx * (Info->bmiHeader.biBitCount >> 3), /* HACK */
BitmapFormat(Info->bmiHeader.biBitCount, Info->bmiHeader.biCompression),
0 < Info->bmiHeader.biHeight ? 0 : BMF_TOPDOWN,
Bits);
}
if (Info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
{
BITMAPCOREHEADER* coreheader = (BITMAPCOREHEADER*) Info;
@ -479,6 +475,22 @@ NtGdiGetDIBitsInternal(HDC hDC,
Bits);
}
if (Info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER))
{
INT one, two, three;
one = DIB_GetDIBWidthBytes(DestSize.cx, Info->bmiHeader.biBitCount),
two = ((DestSize.cx * Info->bmiHeader.biBitCount + 31) & ~31) >> 3;
three = DestSize.cx * (Info->bmiHeader.biBitCount >> 3);
DestBitmap = EngCreateBitmap(DestSize,
/* DIB_GetDIBWidthBytes(DestSize.cx, Info->bmiHeader.biBitCount), */
DestSize.cx * (Info->bmiHeader.biBitCount >> 3), /* HACK */
BitmapFormat(Info->bmiHeader.biBitCount, Info->bmiHeader.biCompression),
0 < Info->bmiHeader.biHeight ? 0 : BMF_TOPDOWN,
Bits);
}
if(DestBitmap == NULL)
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
@ -495,7 +507,7 @@ NtGdiGetDIBitsInternal(HDC hDC,
DestPalette = PALETTE_LockPalette(hDestPalette);
/* FIXME - DestPalette can be NULL!!!! Don't assert here!!! */
ASSERT(DestPalette);
//ASSERT(DestPalette);
DestPaletteType = DestPalette->Mode;
/* Copy palette. */
@ -505,32 +517,27 @@ NtGdiGetDIBitsInternal(HDC hDC,
if (Usage == DIB_RGB_COLORS)
{
for (Index = 0;
Index < (1 << Info->bmiHeader.biBitCount) &&
Index < DestPalette->NumColors;
Index < (1 << Info->bmiHeader.biBitCount) && Index < DestPalette->NumColors;
Index++)
{
Info->bmiColors[Index].rgbRed =
DestPalette->IndexedColors[Index].peRed;
Info->bmiColors[Index].rgbGreen =
DestPalette->IndexedColors[Index].peGreen;
Info->bmiColors[Index].rgbBlue =
DestPalette->IndexedColors[Index].peBlue;
Info->bmiColors[Index].rgbRed = DestPalette->IndexedColors[Index].peRed;
Info->bmiColors[Index].rgbGreen = DestPalette->IndexedColors[Index].peGreen;
Info->bmiColors[Index].rgbBlue = DestPalette->IndexedColors[Index].peBlue;
}
}
if (Usage == DIB_PAL_COLORS)
{
DPRINT1("GetDIBits with DIB_PAL_COLORS isn't implemented yet.");
DPRINT1("GetDIBits with DIB_PAL_COLORS isn't implemented yet\n");
}
}
PALETTE_UnlockPalette(DestPalette);
XlateObj = IntEngCreateXlate(
DestPaletteType, SourcePaletteType, hDestPalette, hSourcePalette);
XlateObj = IntEngCreateXlate(DestPaletteType, SourcePaletteType, hDestPalette, hSourcePalette);
SourcePoint.x = 0;
SourcePoint.y = BitmapObj->SurfObj.sizlBitmap.cy -
(StartScan + ScanLines);
SourcePoint.y = BitmapObj->SurfObj.sizlBitmap.cy - (StartScan + ScanLines);
/* Determine destination rectangle */
DestRect.top = 0;
@ -538,8 +545,12 @@ NtGdiGetDIBitsInternal(HDC hDC,
DestRect.right = DestSize.cx;
DestRect.bottom = DestSize.cy;
if (EngCopyBits(DestSurfObj, &BitmapObj->SurfObj,
NULL, XlateObj, &DestRect, &SourcePoint))
if (EngCopyBits(DestSurfObj,
&BitmapObj->SurfObj,
NULL,
XlateObj,
&DestRect,
&SourcePoint))
{
Result = ScanLines;
}