Alexandre Julliard : gdi32: Make sure that biSizeImage always contains the correct size in internal BITMAPINFO structures .
Alexandre Julliard
julliard at winehq.org
Mon Dec 12 12:25:52 CST 2011
Module: wine
Branch: master
Commit: 82e1a4616cd4802e2c14c057732f6296be73580b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=82e1a4616cd4802e2c14c057732f6296be73580b
Author: Alexandre Julliard <julliard at winehq.org>
Date: Sat Dec 10 13:27:16 2011 +0100
gdi32: Make sure that biSizeImage always contains the correct size in internal BITMAPINFO structures.
---
dlls/gdi32/bitblt.c | 14 +++++++++-----
dlls/gdi32/brush.c | 4 ++--
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c
index abd4dfc..7167c4a 100644
--- a/dlls/gdi32/bitblt.c
+++ b/dlls/gdi32/bitblt.c
@@ -170,7 +170,9 @@ DWORD convert_bits( const BITMAPINFO *src_info, struct bitblt_coords *src,
DWORD err;
dst_info->bmiHeader.biWidth = src->visrect.right - src->visrect.left;
- if (!(ptr = HeapAlloc( GetProcessHeap(), 0, get_dib_image_size( dst_info ))))
+ dst_info->bmiHeader.biSizeImage = get_dib_image_size( dst_info );
+
+ if (!(ptr = HeapAlloc( GetProcessHeap(), 0, dst_info->bmiHeader.biSizeImage )))
return ERROR_OUTOFMEMORY;
err = convert_bitmapinfo( src_info, bits->ptr, src, dst_info, ptr, add_alpha );
@@ -190,8 +192,10 @@ DWORD stretch_bits( const BITMAPINFO *src_info, struct bitblt_coords *src,
dst_info->bmiHeader.biWidth = dst->visrect.right - dst->visrect.left;
dst_info->bmiHeader.biHeight = dst->visrect.bottom - dst->visrect.top;
+ dst_info->bmiHeader.biSizeImage = get_dib_image_size( dst_info );
+
if (src_info->bmiHeader.biHeight < 0) dst_info->bmiHeader.biHeight = -dst_info->bmiHeader.biHeight;
- if (!(ptr = HeapAlloc( GetProcessHeap(), 0, get_dib_image_size( dst_info ))))
+ if (!(ptr = HeapAlloc( GetProcessHeap(), 0, dst_info->bmiHeader.biSizeImage )))
return ERROR_OUTOFMEMORY;
err = stretch_bitmapinfo( src_info, bits->ptr, src, dst_info, ptr, dst, mode );
@@ -208,7 +212,7 @@ static DWORD blend_bits( const BITMAPINFO *src_info, const struct gdi_image_bits
{
if (!dst_bits->is_copy)
{
- int size = get_dib_image_size( dst_info );
+ int size = dst_info->bmiHeader.biSizeImage;
void *ptr = HeapAlloc( GetProcessHeap(), 0, size );
if (!ptr) return ERROR_OUTOFMEMORY;
memcpy( ptr, dst_bits->ptr, size );
@@ -446,11 +450,11 @@ BOOL nulldrv_GradientFill( PHYSDEV dev, TRIVERTEX *vert_array, ULONG nvert,
info->bmiHeader.biClrImportant = 0;
info->bmiHeader.biWidth = dst.visrect.right - dst.visrect.left;
info->bmiHeader.biHeight = dst.visrect.bottom - dst.visrect.top;
- info->bmiHeader.biSizeImage = 0;
+ info->bmiHeader.biSizeImage = get_dib_image_size( info );
dev = GET_DC_PHYSDEV( dc, pPutImage );
err = dev->funcs->pPutImage( dev, 0, 0, info, NULL, NULL, NULL, 0 );
if ((err && err != ERROR_BAD_FORMAT) ||
- !(bits.ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, get_dib_image_size( info ))))
+ !(bits.ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, info->bmiHeader.biSizeImage )))
{
ret = FALSE;
goto done;
diff --git a/dlls/gdi32/brush.c b/dlls/gdi32/brush.c
index 34d3a57..c86421c 100644
--- a/dlls/gdi32/brush.c
+++ b/dlls/gdi32/brush.c
@@ -126,12 +126,12 @@ static BOOL copy_bitmap( BRUSHOBJ *brush, HBITMAP bitmap )
memcpy( &info->bmiHeader + 1, bmp->dib->dsBitfields, sizeof(bmp->dib->dsBitfields) );
else if (info->bmiHeader.biClrUsed)
memcpy( &info->bmiHeader + 1, bmp->color_table, info->bmiHeader.biClrUsed * sizeof(RGBQUAD) );
- if (!(brush->bits.ptr = HeapAlloc( GetProcessHeap(), 0, get_dib_image_size( info ))))
+ if (!(brush->bits.ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage )))
{
HeapFree( GetProcessHeap(), 0, info );
goto done;
}
- memcpy( brush->bits.ptr, bmp->dib->dsBm.bmBits, get_dib_image_size( info ));
+ memcpy( brush->bits.ptr, bmp->dib->dsBm.bmBits, info->bmiHeader.biSizeImage );
brush->bits.is_copy = TRUE;
brush->bits.free = free_heap_bits;
brush->info = info;
More information about the wine-cvs
mailing list