From 6f066ec18a07dea56cf0f544514e5361c434110b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 30 Aug 2011 20:48:51 +0200 Subject: [PATCH] gdi32: Forward the null driver PutImage to the DIB driver since the bits are in DIB format. --- dlls/gdi32/bitmap.c | 68 +++++--------------------------------- dlls/gdi32/mfdrv/objects.c | 1 + 2 files changed, 10 insertions(+), 59 deletions(-) diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index 9e2cd320e4d..5790248b8e1 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -88,73 +88,23 @@ DWORD nulldrv_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAPINFO *inf BITMAPOBJ *bmp; if (!hbitmap) return ERROR_SUCCESS; - if (!(bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP ))) return ERROR_INVALID_HANDLE; - - if (info->bmiHeader.biPlanes != 1) goto update_format; - if (info->bmiHeader.biBitCount != bmp->bitmap.bmBitsPixel) goto update_format; - /* FIXME: check color masks */ if (bits) { - int i, width_bytes = get_dib_stride( info->bmiHeader.biWidth, info->bmiHeader.biBitCount ); - unsigned char *dst_bits, *src_bits; - - if ((src->width != dst->width) || (src->height != dst->height)) + if (!(bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP ))) return ERROR_INVALID_HANDLE; + if (!bmp->bitmap.bmBits) { - GDI_ReleaseObj( hbitmap ); - return ERROR_TRANSFORM_NOT_SUPPORTED; - } - if (src->visrect.left > 0 || src->visrect.right < bmp->bitmap.bmWidth || - dst->visrect.left > 0 || dst->visrect.right < bmp->bitmap.bmWidth) - { - FIXME( "setting partial rows not supported\n" ); - GDI_ReleaseObj( hbitmap ); - return ERROR_NOT_SUPPORTED; - } - if (clip) - { - FIXME( "clip region not supported\n" ); - GDI_ReleaseObj( hbitmap ); - return ERROR_NOT_SUPPORTED; - } - - if (!bmp->bitmap.bmBits && - !(bmp->bitmap.bmBits = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, - bmp->bitmap.bmHeight * width_bytes ))) - { - GDI_ReleaseObj( hbitmap ); - return ERROR_OUTOFMEMORY; - } - dst_bits = (unsigned char *)bmp->bitmap.bmBits + dst->visrect.top * width_bytes; - src_bits = bits->ptr; - if (info->bmiHeader.biHeight > 0) - { - src_bits += (info->bmiHeader.biHeight - 1 - src->visrect.top) * width_bytes; - width_bytes = -width_bytes; - } - else - src_bits += src->visrect.top * width_bytes; - - if (width_bytes != bmp->bitmap.bmWidthBytes) - { - for (i = 0; i < dst->visrect.bottom - dst->visrect.top; i++) + int width_bytes = get_dib_stride( bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel ); + if (!(bmp->bitmap.bmBits = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, + bmp->bitmap.bmHeight * width_bytes ))) { - memcpy( dst_bits, src_bits, bmp->bitmap.bmWidthBytes ); - src_bits += width_bytes; - dst_bits += abs(width_bytes); + GDI_ReleaseObj( hbitmap ); + return ERROR_OUTOFMEMORY; } } - else memcpy( dst_bits, src_bits, width_bytes * (dst->visrect.bottom - dst->visrect.top) ); + GDI_ReleaseObj( hbitmap ); } - GDI_ReleaseObj( hbitmap ); - return ERROR_SUCCESS; - -update_format: - info->bmiHeader.biPlanes = 1; - info->bmiHeader.biBitCount = bmp->bitmap.bmBitsPixel; - if (info->bmiHeader.biHeight > 0) info->bmiHeader.biHeight = -info->bmiHeader.biHeight; - GDI_ReleaseObj( hbitmap ); - return ERROR_BAD_FORMAT; + return dib_driver.pPutImage( NULL, hbitmap, clip, info, bits, src, dst, rop ); } diff --git a/dlls/gdi32/mfdrv/objects.c b/dlls/gdi32/mfdrv/objects.c index 674e7e1f9c0..7a5039d6fb0 100644 --- a/dlls/gdi32/mfdrv/objects.c +++ b/dlls/gdi32/mfdrv/objects.c @@ -202,6 +202,7 @@ INT16 MFDRV_CreateBrushIndirect(PHYSDEV dev, HBRUSH hBrush ) mr->rdParm[1] = DIB_RGB_COLORS; dst_info = (BITMAPINFO *)(mr->rdParm + 2); dst_info->bmiHeader = src_info->bmiHeader; + dst_info->bmiHeader.biClrUsed = 0; cref = GetTextColor( dev->hdc ); dst_info->bmiColors[0].rgbRed = GetRValue(cref); dst_info->bmiColors[0].rgbGreen = GetGValue(cref);