gdi32: Remove the nb_colors fields in the bitmap object, we always allocate a full size color table.

oldstable
Alexandre Julliard 2011-12-09 20:00:36 +01:00
parent c441ebc21d
commit 494bfa866a
5 changed files with 11 additions and 16 deletions

View File

@ -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 )))
{

View File

@ -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 );

View File

@ -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 ))

View File

@ -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)

View File

@ -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 */