From 02d814852dcd1b62340b14dac38930758be42987 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 29 Nov 2005 10:45:40 +0100 Subject: [PATCH] Added support for doing SetBitmapBits on a DIB section. --- dlls/gdi/bitmap.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dlls/gdi/bitmap.c b/dlls/gdi/bitmap.c index 0688c8b72f..a0c6b25802 100644 --- a/dlls/gdi/bitmap.c +++ b/dlls/gdi/bitmap.c @@ -381,6 +381,31 @@ LONG WINAPI SetBitmapBits( count = -count; } + if (bmp->dib) /* simply copy the bits into the DIB */ + { + DIBSECTION *dib = bmp->dib; + char *dest = dib->dsBm.bmBits; + DWORD max = dib->dsBm.bmWidthBytes * dib->dsBm.bmHeight; + if (count > max) count = max; + ret = count; + + if (bmp->dib->dsBmih.biHeight >= 0) /* not top-down, need to flip contents vertically */ + { + dest += dib->dsBm.bmWidthBytes * dib->dsBm.bmHeight; + while (count > 0) + { + dest -= dib->dsBm.bmWidthBytes; + memcpy( dest, bits, min( count, dib->dsBm.bmWidthBytes ) ); + bits = (char *)bits + dib->dsBm.bmWidthBytes; + count -= dib->dsBm.bmWidthBytes; + } + } + else memcpy( dest, bits, count ); + + GDI_ReleaseObj( hbitmap ); + return ret; + } + /* Only get entire lines */ height = count / bmp->bitmap.bmWidthBytes; if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight; -- 2.32.0.93.g670b81a890