gdi32: Forward the null driver GetImage to the DIB driver since the bits are in DIB format.

This commit is contained in:
Alexandre Julliard 2011-08-29 15:55:35 +02:00
parent c268c40fdf
commit bff79eb2b9
4 changed files with 37 additions and 37 deletions

View File

@ -54,55 +54,31 @@ DWORD nulldrv_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 )
{ {
BITMAPOBJ *bmp; BITMAPOBJ *bmp;
int height, width_bytes; DWORD ret;
if (!hbitmap) return ERROR_NOT_SUPPORTED; if (!hbitmap) return ERROR_NOT_SUPPORTED;
if (!(bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP ))) return ERROR_INVALID_HANDLE; if (!(bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP ))) return ERROR_INVALID_HANDLE;
info->bmiHeader.biSize = sizeof(info->bmiHeader); if (bmp->bitmap.bmBits || !bits)
info->bmiHeader.biPlanes = 1;
info->bmiHeader.biBitCount = bmp->bitmap.bmBitsPixel;
info->bmiHeader.biCompression = BI_RGB;
info->bmiHeader.biXPelsPerMeter = 0;
info->bmiHeader.biYPelsPerMeter = 0;
info->bmiHeader.biClrUsed = 0;
info->bmiHeader.biClrImportant = 0;
if (bmp->bitmap.bmBitsPixel == 16)
{ {
DWORD *masks = (DWORD *)info->bmiColors; ret = dib_driver.pGetImage( 0, hbitmap, info, bits, src );
masks[0] = 0x7c00;
masks[1] = 0x03e0;
masks[2] = 0x001f;
info->bmiHeader.biCompression = BI_BITFIELDS;
} }
if (!bits) goto done; else if (!(ret = dib_driver.pGetImage( 0, hbitmap, info, NULL, src )))
height = src->visrect.bottom - src->visrect.top;
width_bytes = get_dib_stride( bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel );
info->bmiHeader.biWidth = bmp->bitmap.bmWidth;
info->bmiHeader.biHeight = -height;
info->bmiHeader.biSizeImage = height * width_bytes;
/* make the source rectangle relative to the returned bits */
src->y -= src->visrect.top;
offset_rect( &src->visrect, 0, -src->visrect.top );
if (bmp->bitmap.bmBits)
{
bits->ptr = (char *)bmp->bitmap.bmBits + src->visrect.top * width_bytes;
bits->is_copy = FALSE;
bits->free = NULL;
}
else
{ {
info->bmiHeader.biHeight = -(src->visrect.bottom - src->visrect.top);
info->bmiHeader.biSizeImage = get_dib_image_size( info );
/* make the source rectangle relative to the returned bits */
src->y -= src->visrect.top;
offset_rect( &src->visrect, 0, -src->visrect.top );
/* return all-zero bits */ /* return all-zero bits */
bits->ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, info->bmiHeader.biSizeImage ); bits->ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, info->bmiHeader.biSizeImage );
bits->is_copy = TRUE; bits->is_copy = TRUE;
bits->free = free_heap_bits; bits->free = free_heap_bits;
} }
done:
GDI_ReleaseObj( hbitmap ); GDI_ReleaseObj( hbitmap );
return ERROR_SUCCESS; return ret;
} }
DWORD nulldrv_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAPINFO *info, DWORD nulldrv_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAPINFO *info,

View File

@ -895,6 +895,22 @@ static void fill_default_color_table( BITMAPINFO *info )
} }
} }
void get_ddb_bitmapinfo( BITMAPOBJ *bmp, BITMAPINFO *info )
{
info->bmiHeader.biSize = sizeof(info->bmiHeader);
info->bmiHeader.biWidth = bmp->bitmap.bmWidth;
info->bmiHeader.biHeight = -bmp->bitmap.bmHeight;
info->bmiHeader.biPlanes = 1;
info->bmiHeader.biBitCount = bmp->bitmap.bmBitsPixel;
info->bmiHeader.biCompression = BI_RGB;
info->bmiHeader.biXPelsPerMeter = 0;
info->bmiHeader.biYPelsPerMeter = 0;
info->bmiHeader.biClrUsed = 0;
info->bmiHeader.biClrImportant = 0;
if (info->bmiHeader.biBitCount <= 8) fill_default_color_table( info );
}
/****************************************************************************** /******************************************************************************
* GetDIBits [GDI32.@] * GetDIBits [GDI32.@]
* *

View File

@ -213,7 +213,14 @@ BOOL init_dib_info_from_bitmapinfo(dib_info *dib, const BITMAPINFO *info, void *
BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_flags flags) BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_flags flags)
{ {
assert(bmp->dib); if (!bmp->dib)
{
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
BITMAPINFO *info = (BITMAPINFO *)buffer;
get_ddb_bitmapinfo( bmp, info );
return init_dib_info_from_bitmapinfo( dib, info, bmp->bitmap.bmBits, flags );
}
return init_dib_info( dib, &bmp->dib->dsBmih, bmp->dib->dsBitfields, 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->nb_colors, bmp->dib->dsBm.bmBits, flags );
} }

View File

@ -308,6 +308,7 @@ extern BOOL BIDI_Reorder( HDC hDC, LPCWSTR lpString, INT uCount, DWORD dwFlags,
LPWSTR lpOutString, INT uCountOut, UINT *lpOrder, WORD **lpGlyphs, INT* cGlyphs ) DECLSPEC_HIDDEN; LPWSTR lpOutString, INT uCountOut, UINT *lpOrder, WORD **lpGlyphs, INT* cGlyphs ) DECLSPEC_HIDDEN;
/* bitmap.c */ /* bitmap.c */
extern void get_ddb_bitmapinfo( BITMAPOBJ *bmp, BITMAPINFO *info ) DECLSPEC_HIDDEN;
extern BOOL get_bitmap_image( HBITMAP hbitmap, BITMAPINFO *info, struct gdi_image_bits *bits ) DECLSPEC_HIDDEN; extern BOOL get_bitmap_image( HBITMAP hbitmap, BITMAPINFO *info, struct gdi_image_bits *bits ) DECLSPEC_HIDDEN;
extern HBITMAP BITMAP_CopyBitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN; extern HBITMAP BITMAP_CopyBitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN;
extern BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, PHYSDEV physdev ) DECLSPEC_HIDDEN; extern BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, PHYSDEV physdev ) DECLSPEC_HIDDEN;