gdi32: "StretchDIBits" with value of zero for "xSrc" and "ySrc"

Vitaliy Margolen wine-devel at
Mon Sep 22 08:37:28 CDT 2008

Mathias Kosch wrote:
> This path fixes Bug#13344.
> The function "StretchDIBits" behaves odd in case of "top-down" bitmaps
> with values of zero for "xSrc" and "ySrc". Tests using Windows Server
> 2003 shew that in this particular case the source rectangle is
> selected starting at the upper left corner of the bitmap. In all other
> cases the rectangle is aligned to the bottom of the bitmap.
> I provided a test case which tests several combinations, especially
> those with some of the values set to zero.
> It passes under "Windows Server 2003 R2 SP2" and Wine 1.1.5 (only)
> with this path applied.

General note - Wine uses 4-spaces indentation, tabs = 8 spaces. Use of tabs
discouraged. Mixing spaces and tabs highly not recommended.

> +#include <stdbool.h>
> +#include <inttypes.h>
Please use windows types instead

> +	struct PIXEL
> +	{
> +		uint8_t blue;
> +		uint8_t green;
> +		uint8_t red;
> +	} __attribute__ ((__packed__));
You should use RGBTRIPLE instead.

> +	HDC hDC = NULL, hMemDC = NULL;
> +	HBITMAP hBitmap = NULL, hOldBitmap = NULL;
What's the point initializing something you will overwrite anyway? Don't do
this, it hides bugs.

> +	pBitmapData = (struct PIXEL*)malloc(nBitmapWidth*nBitmapHeight*sizeof(struct PIXEL));
Malloc should not be used in winelib apps. Use HeapAlloc/HeapFree.

> +	if (!pBitmapData)
> +		ok(0, "Memory allocation failed.\n");
Don't do this. If allocation failed assert or skip the test entirely.


More information about the wine-devel mailing list