Commit d353c95d authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Add a flag to request a default color table from init_dib_info.

parent c5895ead
......@@ -321,20 +321,6 @@ BOOL nulldrv_AlphaBlend( PHYSDEV dst_dev, struct bitblt_coords *dst,
err = dst_dev->funcs->pBlendImage( dst_dev, dst_info, &bits, src, dst, func );
if (err == ERROR_BAD_FORMAT)
{
/* 1-bpp source without a color table uses black & white */
if (src_info->bmiHeader.biBitCount == 1 && !src_info->bmiHeader.biClrUsed)
{
src_info->bmiColors[0].rgbRed = 0;
src_info->bmiColors[0].rgbGreen = 0;
src_info->bmiColors[0].rgbBlue = 0;
src_info->bmiColors[0].rgbReserved = 0;
src_info->bmiColors[1].rgbRed = 0xff;
src_info->bmiColors[1].rgbGreen = 0xff;
src_info->bmiColors[1].rgbBlue = 0xff;
src_info->bmiColors[1].rgbReserved = 0;
src_info->bmiHeader.biClrUsed = 2;
}
err = convert_bits( src_info, src, dst_info, &bits, TRUE );
if (!err) err = dst_dev->funcs->pBlendImage( dst_dev, dst_info, &bits, src, dst, func );
}
......
......@@ -1155,7 +1155,6 @@ void get_ddb_bitmapinfo( BITMAPOBJ *bmp, BITMAPINFO *info )
info->bmiHeader.biYPelsPerMeter = 0;
info->bmiHeader.biClrUsed = 0;
info->bmiHeader.biClrImportant = 0;
if (info->bmiHeader.biBitCount <= 8) fill_default_color_table( info );
}
BITMAPINFO *copy_packed_dib( const BITMAPINFO *src_info, UINT usage )
......
......@@ -927,7 +927,6 @@ static BOOL matching_color_info( const dib_info *dib, const BITMAPINFO *info )
case 8:
{
RGBQUAD *color_table = (RGBQUAD *)((char *)info + info->bmiHeader.biSize);
if (!info->bmiHeader.biClrUsed) return FALSE;
if (dib->color_table_size != info->bmiHeader.biClrUsed) return FALSE;
return !memcmp( color_table, dib->color_table, dib->color_table_size * sizeof(RGBQUAD) );
}
......@@ -1327,7 +1326,7 @@ DWORD blend_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bitbl
if (!init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits, 0 ) )
return ERROR_BAD_FORMAT;
if (!init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, 0 ) )
if (!init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, default_color_table ) )
return ERROR_BAD_FORMAT;
return blend_rect( &dst_dib, &dst->visrect, &src_dib, &src->visrect, NULL, blend );
......@@ -1345,7 +1344,7 @@ DWORD gradient_bitmapinfo( const BITMAPINFO *info, void *bits, TRIVERTEX *vert_a
DWORD ret = ERROR_SUCCESS;
HRGN tmp_rgn = 0;
if (!init_dib_info_from_bitmapinfo( &dib, info, bits, 0 )) return ERROR_BAD_FORMAT;
if (!init_dib_info_from_bitmapinfo( &dib, info, bits, default_color_table )) return ERROR_BAD_FORMAT;
switch (mode)
{
......
......@@ -153,6 +153,11 @@ static BOOL init_dib_info(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD
dib->color_table = color_table;
dib->color_table_size = bi->biClrUsed;
}
else if (flags & default_color_table)
{
dib->color_table = (RGBQUAD *)get_default_color_table( dib->bit_count );
dib->color_table_size = dib->color_table ? (1 << dib->bit_count) : 0;
}
else
{
dib->color_table = NULL;
......@@ -186,10 +191,9 @@ BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_f
{
if (!bmp->dib)
{
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
BITMAPINFO *info = (BITMAPINFO *)buffer;
BITMAPINFO info;
get_ddb_bitmapinfo( bmp, info );
get_ddb_bitmapinfo( bmp, &info );
if (!bmp->bitmap.bmBits)
{
int width_bytes = get_dib_stride( bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel );
......@@ -197,8 +201,7 @@ BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_f
bmp->bitmap.bmHeight * width_bytes );
if (!bmp->bitmap.bmBits) return FALSE;
}
return init_dib_info_from_bitmapinfo( dib, info, bmp->bitmap.bmBits,
flags | private_color_table );
return init_dib_info_from_bitmapinfo( dib, &info, bmp->bitmap.bmBits, flags );
}
return init_dib_info( dib, &bmp->dib->dsBmih, bmp->dib->dsBitfields,
bmp->color_table, bmp->dib->dsBm.bmBits, flags );
......@@ -261,9 +264,9 @@ DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bit
dib_info src_dib, dst_dib;
DWORD ret;
if ( !init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits, 0 ) )
if ( !init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits, default_color_table ) )
return ERROR_BAD_FORMAT;
if ( !init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, 0 ) )
if ( !init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, default_color_table ) )
return ERROR_BAD_FORMAT;
__TRY
......@@ -405,7 +408,7 @@ static HBITMAP dibdrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
free_dib_info(&pdev->dib);
pdev->defer = 0;
if(!init_dib_info_from_bitmapobj(&pdev->dib, bmp, 0))
if(!init_dib_info_from_bitmapobj(&pdev->dib, bmp, default_color_table))
pdev->defer |= DEFER_FORMAT;
GDI_ReleaseObj( bitmap );
......
......@@ -20,7 +20,8 @@
enum dib_info_flags
{
private_color_table = 1
private_color_table = 1,
default_color_table = 2
};
typedef struct
......
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