Alexandre Julliard : gdi32: Get rid of the DIB_GetBitmapInfo function.
Alexandre Julliard
julliard at winehq.org
Thu Aug 4 12:22:11 CDT 2011
Module: wine
Branch: master
Commit: e5ce32e54d3ec34977e9ee7b3cf891b9f983e21d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e5ce32e54d3ec34977e9ee7b3cf891b9f983e21d
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Aug 4 14:40:34 2011 +0200
gdi32: Get rid of the DIB_GetBitmapInfo function.
---
dlls/gdi32/dib.c | 78 +++++++++++----------------------------------
dlls/gdi32/gdi_private.h | 2 -
2 files changed, 19 insertions(+), 61 deletions(-)
diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index d53289b..5d08c6e 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -28,8 +28,7 @@
Most Windows API functions taking a BITMAPINFO* / BITMAPINFOHEADER* also
accept the old "core" structures, and so must WINE.
- You can distinguish them by looking at the first member (bcSize/biSize),
- or use the internal function DIB_GetBitmapInfo.
+ You can distinguish them by looking at the first member (bcSize/biSize).
* The palettes are stored in different formats:
@@ -98,70 +97,35 @@ int bitmap_info_size( const BITMAPINFO * info, WORD coloruse )
}
}
-
-/***********************************************************************
- * DIB_GetBitmapInfo
- *
- * Get the info from a bitmap header.
- * Return 0 for COREHEADER, 1 for INFOHEADER, -1 for error.
- */
-int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
- LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size )
-{
- if (!header) return -1;
- if (header->biSize == sizeof(BITMAPCOREHEADER))
- {
- const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)header;
- *width = core->bcWidth;
- *height = core->bcHeight;
- *planes = core->bcPlanes;
- *bpp = core->bcBitCount;
- *compr = 0;
- *size = 0;
- return 0;
- }
- if (header->biSize >= sizeof(BITMAPINFOHEADER)) /* assume BITMAPINFOHEADER */
- {
- *width = header->biWidth;
- *height = header->biHeight;
- *planes = header->biPlanes;
- *bpp = header->biBitCount;
- *compr = header->biCompression;
- *size = header->biSizeImage;
- return 1;
- }
- ERR("(%d): unknown/wrong size for header\n", header->biSize );
- return -1;
-}
-
/*******************************************************************************************
* Fill out a true BITMAPINFOHEADER from a variable sized BITMAPINFOHEADER / BITMAPCOREHEADER.
*/
static BOOL bitmapinfoheader_from_user_bitmapinfo( BITMAPINFOHEADER *dst, const BITMAPINFOHEADER *info )
{
- LONG width, height;
- WORD planes, bpp;
- DWORD compr, size;
- int bitmap_type = DIB_GetBitmapInfo( info, &width, &height, &planes, &bpp, &compr, &size );
-
- if (bitmap_type == -1) return FALSE;
+ if (!info) return FALSE;
- if (bitmap_type == 1)
+ if (info->biSize == sizeof(BITMAPCOREHEADER))
{
- *dst = *info;
- }
- else
- {
- dst->biWidth = width;
- dst->biHeight = height;
- dst->biPlanes = planes;
- dst->biBitCount = bpp;
- dst->biCompression = compr;
+ const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info;
+ dst->biWidth = core->bcWidth;
+ dst->biHeight = core->bcHeight;
+ dst->biPlanes = core->bcPlanes;
+ dst->biBitCount = core->bcBitCount;
+ dst->biCompression = BI_RGB;
dst->biXPelsPerMeter = 0;
dst->biYPelsPerMeter = 0;
dst->biClrUsed = 0;
dst->biClrImportant = 0;
}
+ else if (info->biSize >= sizeof(BITMAPINFOHEADER)) /* assume BITMAPINFOHEADER */
+ {
+ *dst = *info;
+ }
+ else
+ {
+ WARN( "(%u): unknown/wrong size for header\n", info->biSize );
+ return FALSE;
+ }
dst->biSize = sizeof(*dst);
if (dst->biCompression == BI_RGB || dst->biCompression == BI_BITFIELDS)
@@ -928,11 +892,7 @@ INT WINAPI GetDIBits(
/* 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;
- }
+ if (!bitmapinfoheader_from_user_bitmapinfo( &dst_info->bmiHeader, &info->bmiHeader )) return 0;
dst_info->bmiHeader.biClrUsed = 0;
dst_info->bmiHeader.biClrImportant = 0;
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index 0111951..b24f4eb 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -338,8 +338,6 @@ extern void DC_UpdateXforms( DC * dc ) DECLSPEC_HIDDEN;
/* dib.c */
extern int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) DECLSPEC_HIDDEN;
-extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
- LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size ) DECLSPEC_HIDDEN;
extern DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bitblt_coords *src,
const BITMAPINFO *dst_info, void *dst_bits ) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list