Huw Davies : gdi32: Add a helper to fill out the colour table from the current palette.
Alexandre Julliard
julliard at winehq.org
Fri Jul 22 10:16:00 CDT 2011
Module: wine
Branch: master
Commit: 8cc8552a01728036db1890c9d8821d0f235faabe
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8cc8552a01728036db1890c9d8821d0f235faabe
Author: Huw Davies <huw at codeweavers.com>
Date: Fri Jul 22 15:09:59 2011 +0100
gdi32: Add a helper to fill out the colour table from the current palette.
---
dlls/gdi32/dib.c | 37 +++++++++++++++++++++++++------------
1 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 85a8992..995c5d7 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -209,6 +209,30 @@ static BOOL bitmapinfo_from_user_bitmapinfo( BITMAPINFO *dst, const BITMAPINFO *
return TRUE;
}
+static int fill_color_table_from_palette( BITMAPINFO *info, DC *dc )
+{
+ PALETTEENTRY palEntry[256];
+ int i, colors = (info->bmiHeader.biBitCount > 8) ? 0 : 1 << info->bmiHeader.biBitCount;
+
+ if (info->bmiHeader.biClrUsed) colors = info->bmiHeader.biClrUsed;
+
+ if (!colors) return 0;
+
+ memset( palEntry, 0, sizeof(palEntry) );
+ if (!GetPaletteEntries( dc->hPalette, 0, colors, palEntry ))
+ return 0;
+
+ for (i = 0; i < colors; i++)
+ {
+ info->bmiColors[i].rgbRed = palEntry[i].peRed;
+ info->bmiColors[i].rgbGreen = palEntry[i].peGreen;
+ info->bmiColors[i].rgbBlue = palEntry[i].peBlue;
+ info->bmiColors[i].rgbReserved = 0;
+ }
+
+ return colors;
+}
+
/* nulldrv fallback implementation using SetDIBits/StretchBlt */
INT nulldrv_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT heightDst,
INT xSrc, INT ySrc, INT widthSrc, INT heightSrc, const void *bits,
@@ -715,22 +739,11 @@ INT WINAPI GetDIBits(
case we'll fix up the indices after the format conversion. */
else if ( (bpp > 1 && bpp == bmp->bitmap.bmBitsPixel) || coloruse == DIB_PAL_COLORS )
{
- PALETTEENTRY palEntry[256];
-
- memset( palEntry, 0, sizeof(palEntry) );
- if (!GetPaletteEntries( dc->hPalette, 0, colors, palEntry ))
+ if (!fill_color_table_from_palette( dst_info, dc ))
{
lines = 0;
goto done;
}
-
- for (i = 0; i < colors; i++)
- {
- dst_info->bmiColors[i].rgbRed = palEntry[i].peRed;
- dst_info->bmiColors[i].rgbGreen = palEntry[i].peGreen;
- dst_info->bmiColors[i].rgbBlue = palEntry[i].peBlue;
- dst_info->bmiColors[i].rgbReserved = 0;
- }
}
else
fill_default_color_table( dst_info );
More information about the wine-cvs
mailing list