Alexandre Julliard : gdi32: Create a sanitized BITMAPINFOHEADER in GetDIBits.
Alexandre Julliard
julliard at winehq.org
Thu Aug 4 12:22:10 CDT 2011
Module: wine
Branch: master
Commit: a2c99c7353c521524a0cd582cecd1ccc09ec3b2e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a2c99c7353c521524a0cd582cecd1ccc09ec3b2e
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Aug 4 14:37:32 2011 +0200
gdi32: Create a sanitized BITMAPINFOHEADER in GetDIBits.
---
dlls/gdi32/dib.c | 32 ++++++++++----------------------
1 files changed, 10 insertions(+), 22 deletions(-)
diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 5f3dd93..eebe3dd 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -918,24 +918,24 @@ INT WINAPI GetDIBits(
DC * dc;
BITMAPOBJ * bmp;
int i;
- int bitmap_type;
LONG width;
LONG height;
- WORD planes, bpp;
- DWORD compr, size;
+ WORD bpp;
char dst_bmibuf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
BITMAPINFO *dst_info = (BITMAPINFO *)dst_bmibuf;
unsigned int colors = 0;
const struct gdi_dc_funcs *funcs;
- if (!info) return 0;
-
- bitmap_type = DIB_GetBitmapInfo( &info->bmiHeader, &width, &height, &planes, &bpp, &compr, &size);
- if (bitmap_type == -1)
+ /* Since info may be a BITMAPCOREINFO or any of the larger BITMAPINFO structures, we'll use our
+ own copy and transfer the colour info back at the end */
+ if (!bitmapinfoheader_from_user_bitmapinfo( &dst_info->bmiHeader, &info->bmiHeader ))
{
ERR("Invalid bitmap format\n");
return 0;
}
+ dst_info->bmiHeader.biClrUsed = 0;
+ dst_info->bmiHeader.biClrImportant = 0;
+
if (!(dc = get_dc_ptr( hdc )))
{
SetLastError( ERROR_INVALID_PARAMETER );
@@ -951,27 +951,15 @@ INT WINAPI GetDIBits(
funcs = bmp->funcs;
if (bmp->dib) funcs = dc->dibdrv.dev.funcs;
+ width = dst_info->bmiHeader.biWidth;
+ height = dst_info->bmiHeader.biHeight;
+ bpp = dst_info->bmiHeader.biBitCount;
if (bpp == 0) /* query bitmap info only */
{
lines = fill_query_info( info, bmp );
goto done;
}
- /* Since info may be a BITMAPCOREINFO or any of the larger BITMAPINFO structures, we'll use our
- own copy and transfer the colour info back at the end */
-
- dst_info->bmiHeader.biSize = sizeof(dst_info->bmiHeader);
- dst_info->bmiHeader.biWidth = width;
- dst_info->bmiHeader.biHeight = height;
- dst_info->bmiHeader.biPlanes = planes;
- dst_info->bmiHeader.biBitCount = bpp;
- dst_info->bmiHeader.biCompression = compr;
- dst_info->bmiHeader.biSizeImage = get_dib_image_size( dst_info );
- dst_info->bmiHeader.biXPelsPerMeter = 0;
- dst_info->bmiHeader.biYPelsPerMeter = 0;
- dst_info->bmiHeader.biClrUsed = 0;
- dst_info->bmiHeader.biClrImportant = 0;
-
switch (bpp)
{
case 1:
More information about the wine-cvs
mailing list