Commit 494bfa86 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Remove the nb_colors fields in the bitmap object, we always allocate a…

gdi32: Remove the nb_colors fields in the bitmap object, we always allocate a full size color table.
parent c441ebc2
......@@ -300,7 +300,6 @@ HBITMAP WINAPI CreateBitmapIndirect( const BITMAP *bmp )
bmpobj->funcs = &null_driver;
bmpobj->dib = NULL;
bmpobj->color_table = NULL;
bmpobj->nb_colors = 0;
if (!(hbitmap = alloc_gdi_handle( &bmpobj->header, OBJ_BITMAP, &bitmap_funcs )))
{
......
......@@ -122,10 +122,10 @@ static BOOL copy_bitmap( BRUSHOBJ *brush, HBITMAP bitmap )
bitmap_info_size( (BITMAPINFO *)&bmp->dib->dsBmih, DIB_RGB_COLORS ));
if (!info) goto done;
info->bmiHeader = bmp->dib->dsBmih;
if (bmp->dib->dsBmih.biCompression == BI_BITFIELDS)
if (info->bmiHeader.biCompression == BI_BITFIELDS)
memcpy( &info->bmiHeader + 1, bmp->dib->dsBitfields, sizeof(bmp->dib->dsBitfields) );
else if (bmp->nb_colors)
memcpy( &info->bmiHeader + 1, bmp->color_table, bmp->nb_colors * sizeof(RGBQUAD) );
else if (info->bmiHeader.biClrUsed)
memcpy( &info->bmiHeader + 1, bmp->color_table, info->bmiHeader.biClrUsed * sizeof(RGBQUAD) );
if (!(brush->bits.ptr = HeapAlloc( GetProcessHeap(), 0, get_dib_image_size( info ))))
{
HeapFree( GetProcessHeap(), 0, info );
......
......@@ -894,11 +894,10 @@ UINT WINAPI SetDIBColorTable( HDC hdc, UINT startpos, UINT entries, CONST RGBQUA
/* Check if currently selected bitmap is a DIB */
if (bitmap->color_table)
{
if (startpos < bitmap->nb_colors)
if (startpos < bitmap->dib->dsBmih.biClrUsed)
{
if (startpos + entries > bitmap->nb_colors) entries = bitmap->nb_colors - startpos;
memcpy(bitmap->color_table + startpos, colors, entries * sizeof(RGBQUAD));
result = entries;
result = min( entries, bitmap->dib->dsBmih.biClrUsed - startpos );
memcpy(bitmap->color_table + startpos, colors, result * sizeof(RGBQUAD));
}
}
GDI_ReleaseObj( dc->hBitmap );
......@@ -925,11 +924,10 @@ UINT WINAPI GetDIBColorTable( HDC hdc, UINT startpos, UINT entries, RGBQUAD *col
/* Check if currently selected bitmap is a DIB */
if (bitmap->color_table)
{
if (startpos < bitmap->nb_colors)
if (startpos < bitmap->dib->dsBmih.biClrUsed)
{
if (startpos + entries > bitmap->nb_colors) entries = bitmap->nb_colors - startpos;
memcpy(colors, bitmap->color_table + startpos, entries * sizeof(RGBQUAD));
result = entries;
result = min( entries, bitmap->dib->dsBmih.biClrUsed - startpos );
memcpy(colors, bitmap->color_table + startpos, result * sizeof(RGBQUAD));
}
}
GDI_ReleaseObj( dc->hBitmap );
......@@ -1534,7 +1532,6 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, CONST BITMAPINFO *bmi, UINT usage,
bmp->dib = dib;
bmp->funcs = physdev->funcs;
bmp->color_table = color_table;
bmp->nb_colors = dib->dsBmih.biClrUsed;
GDI_ReleaseObj( ret );
if (!physdev->funcs->pCreateDIBSection( physdev, ret, info, usage ))
......
......@@ -206,7 +206,7 @@ BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_f
flags | private_color_table );
}
return init_dib_info( dib, &bmp->dib->dsBmih, bmp->dib->dsBitfields,
bmp->color_table, bmp->nb_colors, bmp->dib->dsBm.bmBits, flags );
bmp->color_table, bmp->dib->dsBmih.biClrUsed, bmp->dib->dsBm.bmBits, flags );
}
static void clear_dib_info(dib_info *dib)
......
......@@ -179,8 +179,7 @@ typedef struct tagBITMAPOBJ
const struct gdi_dc_funcs *funcs; /* DC function table */
/* For device-independent bitmaps: */
DIBSECTION *dib;
RGBQUAD *color_table; /* DIB color table if <= 8bpp */
UINT nb_colors; /* number of colors in table */
RGBQUAD *color_table; /* DIB color table if <= 8bpp (always 1 << bpp in size) */
} BITMAPOBJ;
/* bidi.c */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment