mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:52:56 +00:00
- 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:
parent
90c3978be9
commit
a98103c630
1 changed files with 207 additions and 196 deletions
|
@ -377,9 +377,9 @@ NtGdiGetDIBitsInternal(HDC hDC,
|
||||||
DC_UnlockDc(Dc);
|
DC_UnlockDc(Dc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hSourcePalette = Dc->w.hPalette;
|
hSourcePalette = Dc->w.hPalette;
|
||||||
/* FIXME: This is incorrect. hDestPalette should be something other. */
|
hDestPalette = Dc->w.hPalette; // unsure of this (Ged)
|
||||||
hDestPalette = Dc->DevInfo->hpalDefault;
|
|
||||||
DC_UnlockDc(Dc);
|
DC_UnlockDc(Dc);
|
||||||
|
|
||||||
/* Get pointer to the source bitmap object. */
|
/* Get pointer to the source bitmap object. */
|
||||||
|
@ -400,6 +400,7 @@ NtGdiGetDIBitsInternal(HDC hDC,
|
||||||
coreheader->bcBitCount = BitsPerFormat(BitmapObj->SurfObj.iBitmapFormat);
|
coreheader->bcBitCount = BitsPerFormat(BitmapObj->SurfObj.iBitmapFormat);
|
||||||
|
|
||||||
coreheader->bcHeight = BitmapObj->SurfObj.sizlBitmap.cy;
|
coreheader->bcHeight = BitmapObj->SurfObj.sizlBitmap.cy;
|
||||||
|
|
||||||
if (BitmapObj->SurfObj.lDelta > 0)
|
if (BitmapObj->SurfObj.lDelta > 0)
|
||||||
coreheader->bcHeight = -coreheader->bcHeight;
|
coreheader->bcHeight = -coreheader->bcHeight;
|
||||||
|
|
||||||
|
@ -419,8 +420,12 @@ NtGdiGetDIBitsInternal(HDC hDC,
|
||||||
{
|
{
|
||||||
switch (BitmapObj->SurfObj.iBitmapFormat)
|
switch (BitmapObj->SurfObj.iBitmapFormat)
|
||||||
{
|
{
|
||||||
case BMF_1BPP: case BMF_4BPP: case BMF_8BPP:
|
case BMF_1BPP:
|
||||||
case BMF_16BPP: case BMF_24BPP: case BMF_32BPP:
|
case BMF_4BPP:
|
||||||
|
case BMF_8BPP:
|
||||||
|
case BMF_16BPP:
|
||||||
|
case BMF_24BPP:
|
||||||
|
case BMF_32BPP:
|
||||||
Info->bmiHeader.biCompression = BI_RGB;
|
Info->bmiHeader.biCompression = BI_RGB;
|
||||||
break;
|
break;
|
||||||
case BMF_4RLE:
|
case BMF_4RLE:
|
||||||
|
@ -436,10 +441,11 @@ NtGdiGetDIBitsInternal(HDC hDC,
|
||||||
Info->bmiHeader.biCompression = BI_PNG;
|
Info->bmiHeader.biCompression = BI_PNG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info->bmiHeader.biSizeImage = BitmapObj->SurfObj.cjBits;
|
Info->bmiHeader.biSizeImage = BitmapObj->SurfObj.cjBits;
|
||||||
Info->bmiHeader.biXPelsPerMeter = 0; /* FIXME */
|
Info->bmiHeader.biXPelsPerMeter = 0; /* FIXME */
|
||||||
Info->bmiHeader.biYPelsPerMeter = 0; /* FIXME */
|
Info->bmiHeader.biYPelsPerMeter = 0; /* FIXME */
|
||||||
Info->bmiHeader.biClrUsed =
|
Info->bmiHeader.biClrUsed = 0;
|
||||||
Info->bmiHeader.biClrImportant = 1 << Info->bmiHeader.biBitCount; /* FIXME */
|
Info->bmiHeader.biClrImportant = 1 << Info->bmiHeader.biBitCount; /* FIXME */
|
||||||
Result = BitmapObj->SurfObj.sizlBitmap.cy;
|
Result = BitmapObj->SurfObj.sizlBitmap.cy;
|
||||||
}
|
}
|
||||||
|
@ -458,16 +464,6 @@ NtGdiGetDIBitsInternal(HDC hDC,
|
||||||
DestSize.cy = ScanLines;
|
DestSize.cy = ScanLines;
|
||||||
|
|
||||||
DestBitmap = NULL;
|
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))
|
if (Info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
|
||||||
{
|
{
|
||||||
BITMAPCOREHEADER* coreheader = (BITMAPCOREHEADER*) Info;
|
BITMAPCOREHEADER* coreheader = (BITMAPCOREHEADER*) Info;
|
||||||
|
@ -479,6 +475,22 @@ NtGdiGetDIBitsInternal(HDC hDC,
|
||||||
Bits);
|
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)
|
if(DestBitmap == NULL)
|
||||||
{
|
{
|
||||||
BITMAPOBJ_UnlockBitmap(BitmapObj);
|
BITMAPOBJ_UnlockBitmap(BitmapObj);
|
||||||
|
@ -495,7 +507,7 @@ NtGdiGetDIBitsInternal(HDC hDC,
|
||||||
|
|
||||||
DestPalette = PALETTE_LockPalette(hDestPalette);
|
DestPalette = PALETTE_LockPalette(hDestPalette);
|
||||||
/* FIXME - DestPalette can be NULL!!!! Don't assert here!!! */
|
/* FIXME - DestPalette can be NULL!!!! Don't assert here!!! */
|
||||||
ASSERT(DestPalette);
|
//ASSERT(DestPalette);
|
||||||
DestPaletteType = DestPalette->Mode;
|
DestPaletteType = DestPalette->Mode;
|
||||||
|
|
||||||
/* Copy palette. */
|
/* Copy palette. */
|
||||||
|
@ -505,32 +517,27 @@ NtGdiGetDIBitsInternal(HDC hDC,
|
||||||
if (Usage == DIB_RGB_COLORS)
|
if (Usage == DIB_RGB_COLORS)
|
||||||
{
|
{
|
||||||
for (Index = 0;
|
for (Index = 0;
|
||||||
Index < (1 << Info->bmiHeader.biBitCount) &&
|
Index < (1 << Info->bmiHeader.biBitCount) && Index < DestPalette->NumColors;
|
||||||
Index < DestPalette->NumColors;
|
|
||||||
Index++)
|
Index++)
|
||||||
{
|
{
|
||||||
Info->bmiColors[Index].rgbRed =
|
Info->bmiColors[Index].rgbRed = DestPalette->IndexedColors[Index].peRed;
|
||||||
DestPalette->IndexedColors[Index].peRed;
|
Info->bmiColors[Index].rgbGreen = DestPalette->IndexedColors[Index].peGreen;
|
||||||
Info->bmiColors[Index].rgbGreen =
|
Info->bmiColors[Index].rgbBlue = DestPalette->IndexedColors[Index].peBlue;
|
||||||
DestPalette->IndexedColors[Index].peGreen;
|
|
||||||
Info->bmiColors[Index].rgbBlue =
|
|
||||||
DestPalette->IndexedColors[Index].peBlue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Usage == DIB_PAL_COLORS)
|
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);
|
PALETTE_UnlockPalette(DestPalette);
|
||||||
|
|
||||||
XlateObj = IntEngCreateXlate(
|
XlateObj = IntEngCreateXlate(DestPaletteType, SourcePaletteType, hDestPalette, hSourcePalette);
|
||||||
DestPaletteType, SourcePaletteType, hDestPalette, hSourcePalette);
|
|
||||||
|
|
||||||
SourcePoint.x = 0;
|
SourcePoint.x = 0;
|
||||||
SourcePoint.y = BitmapObj->SurfObj.sizlBitmap.cy -
|
SourcePoint.y = BitmapObj->SurfObj.sizlBitmap.cy - (StartScan + ScanLines);
|
||||||
(StartScan + ScanLines);
|
|
||||||
|
|
||||||
/* Determine destination rectangle */
|
/* Determine destination rectangle */
|
||||||
DestRect.top = 0;
|
DestRect.top = 0;
|
||||||
|
@ -538,8 +545,12 @@ NtGdiGetDIBitsInternal(HDC hDC,
|
||||||
DestRect.right = DestSize.cx;
|
DestRect.right = DestSize.cx;
|
||||||
DestRect.bottom = DestSize.cy;
|
DestRect.bottom = DestSize.cy;
|
||||||
|
|
||||||
if (EngCopyBits(DestSurfObj, &BitmapObj->SurfObj,
|
if (EngCopyBits(DestSurfObj,
|
||||||
NULL, XlateObj, &DestRect, &SourcePoint))
|
&BitmapObj->SurfObj,
|
||||||
|
NULL,
|
||||||
|
XlateObj,
|
||||||
|
&DestRect,
|
||||||
|
&SourcePoint))
|
||||||
{
|
{
|
||||||
Result = ScanLines;
|
Result = ScanLines;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue