gdi32: Add a helper to build a color table from the DIB_PAL_COLORS bitmap info.
This commit is contained in:
parent
71199eab77
commit
91d19b4b17
|
@ -233,6 +233,28 @@ static int fill_color_table_from_palette( BITMAPINFO *info, HDC hdc )
|
|||
return colors;
|
||||
}
|
||||
|
||||
int fill_color_table_from_pal_colors( HDC hdc, const BITMAPINFO *info, RGBQUAD *color_table )
|
||||
{
|
||||
PALETTEENTRY entries[256];
|
||||
HPALETTE palette;
|
||||
const WORD *index = (const WORD *)info->bmiColors;
|
||||
int i, count, colors = get_dib_num_of_colors( info );
|
||||
|
||||
if (!colors) return 0;
|
||||
if (!(palette = GetCurrentObject( hdc, OBJ_PAL ))) return 0;
|
||||
if (!(count = GetPaletteEntries( palette, 0, colors, entries ))) return 0;
|
||||
|
||||
for (i = 0; i < colors; i++, index++)
|
||||
{
|
||||
PALETTEENTRY *entry = &entries[*index % count];
|
||||
color_table[i].rgbRed = entry->peRed;
|
||||
color_table[i].rgbGreen = entry->peGreen;
|
||||
color_table[i].rgbBlue = entry->peBlue;
|
||||
color_table[i].rgbReserved = 0;
|
||||
}
|
||||
return colors;
|
||||
}
|
||||
|
||||
static void *get_pixel_ptr( const BITMAPINFO *info, void *bits, int x, int y )
|
||||
{
|
||||
const int width = info->bmiHeader.biWidth, height = info->bmiHeader.biHeight;
|
||||
|
@ -1383,11 +1405,10 @@ HBITMAP WINAPI CreateDIBitmap( HDC hdc, const BITMAPINFOHEADER *header,
|
|||
}
|
||||
|
||||
/* Copy/synthesize RGB palette from BITMAPINFO */
|
||||
static void DIB_CopyColorTable( DC *dc, BITMAPOBJ *bmp, WORD coloruse, const BITMAPINFO *info )
|
||||
static void DIB_CopyColorTable( HDC hdc, BITMAPOBJ *bmp, WORD coloruse, const BITMAPINFO *info )
|
||||
{
|
||||
unsigned int colors, i;
|
||||
unsigned int colors = get_dib_num_of_colors( info );
|
||||
|
||||
colors = get_dib_num_of_colors( info );
|
||||
if (!(bmp->color_table = HeapAlloc(GetProcessHeap(), 0, colors * sizeof(RGBQUAD) ))) return;
|
||||
bmp->nb_colors = colors;
|
||||
|
||||
|
@ -1397,18 +1418,7 @@ static void DIB_CopyColorTable( DC *dc, BITMAPOBJ *bmp, WORD coloruse, const BIT
|
|||
}
|
||||
else
|
||||
{
|
||||
PALETTEENTRY entries[256];
|
||||
const WORD *index = (const WORD *)info->bmiColors;
|
||||
UINT count = GetPaletteEntries( dc->hPalette, 0, colors, entries );
|
||||
|
||||
for (i = 0; i < colors; i++, index++)
|
||||
{
|
||||
PALETTEENTRY *entry = &entries[*index % count];
|
||||
bmp->color_table[i].rgbRed = entry->peRed;
|
||||
bmp->color_table[i].rgbGreen = entry->peGreen;
|
||||
bmp->color_table[i].rgbBlue = entry->peBlue;
|
||||
bmp->color_table[i].rgbReserved = 0;
|
||||
}
|
||||
fill_color_table_from_pal_colors( hdc, info, bmp->color_table );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1521,7 +1531,7 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, CONST BITMAPINFO *bmi, UINT usage,
|
|||
bmp->dib = dib;
|
||||
bmp->funcs = physdev->funcs;
|
||||
/* create local copy of DIB palette */
|
||||
if (info->bmiHeader.biBitCount <= 8) DIB_CopyColorTable( dc, bmp, usage, info );
|
||||
if (info->bmiHeader.biBitCount <= 8) DIB_CopyColorTable( hdc, bmp, usage, info );
|
||||
GDI_ReleaseObj( ret );
|
||||
|
||||
if (!physdev->funcs->pCreateDIBSection( physdev, ret, info, usage ))
|
||||
|
|
|
@ -162,7 +162,7 @@ static BOOL init_dib_info(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL init_dib_info_from_brush(dib_info *dib, const BITMAPINFO *bi, void *bits, UINT usage, HPALETTE palette)
|
||||
BOOL init_dib_info_from_brush(dib_info *dib, const BITMAPINFO *bi, void *bits, UINT usage, HDC hdc)
|
||||
{
|
||||
DWORD *masks = (bi->bmiHeader.biCompression == BI_BITFIELDS) ? (DWORD *)bi->bmiColors : NULL;
|
||||
RGBQUAD *color_table = NULL, pal_table[256];
|
||||
|
@ -172,17 +172,7 @@ BOOL init_dib_info_from_brush(dib_info *dib, const BITMAPINFO *bi, void *bits, U
|
|||
{
|
||||
if(usage == DIB_PAL_COLORS)
|
||||
{
|
||||
PALETTEENTRY entries[256];
|
||||
const WORD *index = (const WORD *)bi->bmiColors;
|
||||
UINT i, count = GetPaletteEntries( palette, 0, num_colors, entries );
|
||||
for (i = 0; i < num_colors; i++, index++)
|
||||
{
|
||||
PALETTEENTRY *entry = &entries[*index % count];
|
||||
pal_table[i].rgbRed = entry->peRed;
|
||||
pal_table[i].rgbGreen = entry->peGreen;
|
||||
pal_table[i].rgbBlue = entry->peBlue;
|
||||
pal_table[i].rgbReserved = 0;
|
||||
}
|
||||
fill_color_table_from_pal_colors( hdc, bi, pal_table );
|
||||
color_table = pal_table;
|
||||
}
|
||||
else color_table = (RGBQUAD *)bi->bmiColors;
|
||||
|
|
|
@ -224,7 +224,7 @@ extern void get_rop_codes(INT rop, struct rop_codes *codes) DECLSPEC_HIDDEN;
|
|||
extern void calc_and_xor_masks(INT rop, DWORD color, DWORD *and, DWORD *xor) DECLSPEC_HIDDEN;
|
||||
extern void update_brush_rop( dibdrv_physdev *pdev, INT rop ) DECLSPEC_HIDDEN;
|
||||
extern void reset_dash_origin(dibdrv_physdev *pdev) DECLSPEC_HIDDEN;
|
||||
extern BOOL init_dib_info_from_brush(dib_info *dib, const BITMAPINFO *bi, void *bits, UINT usage, HPALETTE pal) DECLSPEC_HIDDEN;
|
||||
extern BOOL init_dib_info_from_brush(dib_info *dib, const BITMAPINFO *bi, void *bits, UINT usage, HDC hdc) DECLSPEC_HIDDEN;
|
||||
extern BOOL init_dib_info_from_bitmapinfo(dib_info *dib, const BITMAPINFO *info, void *bits,
|
||||
enum dib_info_flags flags) DECLSPEC_HIDDEN;
|
||||
extern BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_flags flags) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -1338,9 +1338,8 @@ static BOOL pattern_brush(dibdrv_physdev *pdev, dib_info *dib, int num, const RE
|
|||
if (pdev->brush_pattern_usage == DIB_PAL_COLORS)
|
||||
{
|
||||
dib_info pattern;
|
||||
HPALETTE pal = GetCurrentObject( pdev->dev.hdc, OBJ_PAL );
|
||||
if (!init_dib_info_from_brush( &pattern, pdev->brush_pattern_info,
|
||||
pdev->brush_pattern_bits, DIB_PAL_COLORS, pal ))
|
||||
pdev->brush_pattern_bits, DIB_PAL_COLORS, pdev->dev.hdc ))
|
||||
return FALSE;
|
||||
select_pattern_brush( pdev, &pattern );
|
||||
free_dib_info( &pattern );
|
||||
|
|
|
@ -235,6 +235,7 @@ extern void DC_UpdateXforms( DC * dc ) DECLSPEC_HIDDEN;
|
|||
|
||||
/* dib.c */
|
||||
extern int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) DECLSPEC_HIDDEN;
|
||||
extern int fill_color_table_from_pal_colors( HDC hdc, const BITMAPINFO *info, RGBQUAD *color_table ) DECLSPEC_HIDDEN;
|
||||
extern void fill_default_color_table( BITMAPINFO *info ) DECLSPEC_HIDDEN;
|
||||
extern void get_ddb_bitmapinfo( BITMAPOBJ *bmp, BITMAPINFO *info ) DECLSPEC_HIDDEN;
|
||||
extern BITMAPINFO *copy_packed_dib( const BITMAPINFO *src_info, UINT usage ) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue