gdi32: Simplify dibdrv_GetImage by merging the stand-alone and selected bitmap cases.
This commit is contained in:
parent
37423cec7c
commit
c5f484597f
|
@ -380,6 +380,9 @@ static void set_color_info( const dib_info *dib, BITMAPINFO *info )
|
||||||
static DWORD dibdrv_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info,
|
static DWORD dibdrv_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info,
|
||||||
struct gdi_image_bits *bits, struct bitblt_coords *src )
|
struct gdi_image_bits *bits, struct bitblt_coords *src )
|
||||||
{
|
{
|
||||||
|
DWORD ret = ERROR_SUCCESS;
|
||||||
|
dib_info *dib, stand_alone;
|
||||||
|
|
||||||
TRACE( "%p %p %p\n", dev, hbitmap, info );
|
TRACE( "%p %p %p\n", dev, hbitmap, info );
|
||||||
|
|
||||||
info->bmiHeader.biSize = sizeof(info->bmiHeader);
|
info->bmiHeader.biSize = sizeof(info->bmiHeader);
|
||||||
|
@ -397,64 +400,39 @@ static DWORD dibdrv_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info,
|
||||||
if (!bmp) return ERROR_INVALID_HANDLE;
|
if (!bmp) return ERROR_INVALID_HANDLE;
|
||||||
assert(bmp->dib);
|
assert(bmp->dib);
|
||||||
|
|
||||||
info->bmiHeader.biWidth = bmp->dib->dsBmih.biWidth;
|
if (!init_dib_info( &stand_alone, &bmp->dib->dsBmih, bmp->dib->dsBitfields,
|
||||||
info->bmiHeader.biHeight = bmp->dib->dsBmih.biHeight;
|
bmp->color_table, bmp->nb_colors, bmp->dib->dsBm.bmBits, 0 ))
|
||||||
info->bmiHeader.biBitCount = bmp->dib->dsBmih.biBitCount;
|
|
||||||
info->bmiHeader.biSizeImage = get_dib_image_size( (BITMAPINFO *)&bmp->dib->dsBmih );
|
|
||||||
|
|
||||||
switch (info->bmiHeader.biBitCount)
|
|
||||||
{
|
{
|
||||||
case 1:
|
ret = ERROR_BAD_FORMAT;
|
||||||
case 4:
|
goto done;
|
||||||
case 8:
|
|
||||||
if (bmp->color_table)
|
|
||||||
{
|
|
||||||
info->bmiHeader.biClrUsed = min( bmp->nb_colors, 1 << info->bmiHeader.biBitCount );
|
|
||||||
memcpy( info->bmiColors, bmp->color_table, info->bmiHeader.biClrUsed * sizeof(RGBQUAD) );
|
|
||||||
}
|
}
|
||||||
break;
|
dib = &stand_alone;
|
||||||
case 16:
|
|
||||||
info->bmiHeader.biCompression = BI_BITFIELDS;
|
|
||||||
memcpy( info->bmiColors, bmp->dib->dsBitfields, sizeof(bmp->dib->dsBitfields) );
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
if (bmp->dib->dsBmih.biCompression == BI_BITFIELDS &&
|
|
||||||
memcmp( bmp->dib->dsBitfields, bit_fields_888, sizeof(bmp->dib->dsBitfields) ))
|
|
||||||
{
|
|
||||||
info->bmiHeader.biCompression = BI_BITFIELDS;
|
|
||||||
memcpy( info->bmiColors, bmp->dib->dsBitfields, sizeof(bmp->dib->dsBitfields) );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (bits)
|
|
||||||
{
|
|
||||||
bits->ptr = bmp->dib->dsBm.bmBits;
|
|
||||||
bits->is_copy = FALSE;
|
|
||||||
bits->free = NULL;
|
|
||||||
}
|
|
||||||
GDI_ReleaseObj( hbitmap );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
||||||
|
dib = &pdev->dib;
|
||||||
|
}
|
||||||
|
|
||||||
info->bmiHeader.biWidth = pdev->dib.width;
|
info->bmiHeader.biWidth = dib->width;
|
||||||
info->bmiHeader.biHeight = pdev->dib.stride > 0 ? -pdev->dib.height : pdev->dib.height;
|
info->bmiHeader.biHeight = dib->stride > 0 ? -dib->height : dib->height;
|
||||||
info->bmiHeader.biBitCount = pdev->dib.bit_count;
|
info->bmiHeader.biBitCount = dib->bit_count;
|
||||||
info->bmiHeader.biSizeImage = pdev->dib.height * abs(pdev->dib.stride);
|
info->bmiHeader.biSizeImage = dib->height * abs( dib->stride );
|
||||||
|
|
||||||
set_color_info( &pdev->dib, info );
|
set_color_info( dib, info );
|
||||||
|
|
||||||
if (bits)
|
if (bits)
|
||||||
{
|
{
|
||||||
bits->ptr = pdev->dib.bits;
|
bits->ptr = dib->bits;
|
||||||
if (pdev->dib.stride < 0)
|
if (dib->stride < 0)
|
||||||
bits->ptr = (char *)bits->ptr + (pdev->dib.height - 1) * pdev->dib.stride;
|
bits->ptr = (char *)bits->ptr + (dib->height - 1) * dib->stride;
|
||||||
bits->is_copy = FALSE;
|
bits->is_copy = FALSE;
|
||||||
bits->free = NULL;
|
bits->free = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return ERROR_SUCCESS;
|
done:
|
||||||
|
if (hbitmap) GDI_ReleaseObj( hbitmap );
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL matching_color_info( const dib_info *dib, const BITMAPINFO *info )
|
static BOOL matching_color_info( const dib_info *dib, const BITMAPINFO *info )
|
||||||
|
|
Loading…
Reference in New Issue