From e7c523b135a8e36c22df34e518690e134db27448 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 30 Aug 2011 21:26:02 +0200 Subject: [PATCH] gdi32: Use SetDIBits to set the initial bits of a DDB. --- dlls/gdi32/bitmap.c | 44 +++----------------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index 5790248b8e1..3a4cacac925 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -609,52 +609,14 @@ static void set_initial_bitmap_bits( HBITMAP hbitmap, BITMAPOBJ *bmp ) { char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; BITMAPINFO *info = (BITMAPINFO *)buffer; - DWORD err; - int width_bytes; - struct bitblt_coords src, dst; - struct gdi_image_bits bits; if (!bmp->bitmap.bmBits) return; if (bmp->funcs->pPutImage == nulldrv_PutImage) return; - width_bytes = get_dib_stride( bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel ); - - src.visrect.left = src.x = 0; - src.visrect.top = src.y = 0; - src.visrect.right = src.width = bmp->bitmap.bmWidth; - src.visrect.bottom = src.height = bmp->bitmap.bmHeight; - dst = src; - - bits.ptr = bmp->bitmap.bmBits; - bits.is_copy = TRUE; - bits.free = free_heap_bits; + get_ddb_bitmapinfo( bmp, info ); + SetDIBits( 0, hbitmap, 0, bmp->bitmap.bmHeight, bmp->bitmap.bmBits, info, DIB_RGB_COLORS ); + HeapFree( GetProcessHeap(), 0, bmp->bitmap.bmBits ); bmp->bitmap.bmBits = NULL; - - /* query the color info */ - info->bmiHeader.biSize = sizeof(info->bmiHeader); - 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; - info->bmiHeader.biWidth = 0; - info->bmiHeader.biHeight = 0; - info->bmiHeader.biSizeImage = 0; - err = bmp->funcs->pPutImage( NULL, hbitmap, 0, info, NULL, NULL, NULL, SRCCOPY ); - - if (!err || err == ERROR_BAD_FORMAT) - { - info->bmiHeader.biPlanes = 1; - info->bmiHeader.biBitCount = bmp->bitmap.bmBitsPixel; - info->bmiHeader.biWidth = bmp->bitmap.bmWidth; - info->bmiHeader.biHeight = -dst.height; - info->bmiHeader.biSizeImage = dst.height * width_bytes; - bmp->funcs->pPutImage( NULL, hbitmap, 0, info, &bits, &src, &dst, SRCCOPY ); - } - - if (bits.free) bits.free( &bits ); } /***********************************************************************