gdi32: "StretchDIBits" seems to use the wrong picture offset

Mathias Kosch info at
Sat Jul 19 13:04:26 CDT 2008

Currently I'm trying to fix Bug#13344.
I figured out that the problems seems to be caused by the function
"StretchDIBits" inside "dlls/gdi32/dib.c".

When I run "Digital Photo Professional" and open images in the
editor window in "fit to window" mode all images are shifted to top so
that I cannot totally see them.
I provided a screenshot as attachment for you to see. The picture was
colored to purple to reduce bandwidth. The dimensions of the visible
image are 1276 x 850 pixels. The picture is shifted upwards by exactly
174 pixels, so a black bar appears at the bottom.

I modified my local copy of "dib.c" (modifications as attachment) to
output its parameters. The produced (extract of the) output is
attached as "output.txt".
The function "StretchDIBits" is called correctly. It shall display a
portion of the bitmap at position (0, 40) of dimensions (1276, 850).
This function produces two calls to "StretchBlt". (In my case only the
second one is called.) The parameters it passes to "StretchBlt" appear
to be wrong because (in the second call) "ySrc" is set to 174 which
explains the pixel shift. If I adjust "ySrc" to 0 all images are
displayed correctly.

I looked at the code of "SetDIBits". It seems that it doesn't make any
difference between bottom-up or top-down DIBs except that the pixel
data is mirrored in y direction. I assume Windows does it the same way,
but didn't verify it.
However "StretchDIBits" wants to differentiate between the two cases
by setting the y offset to "abs(height)-heightSrc-ySrc".
I think only "ySrc" should be used as y offset. However since I'm not
absolutely sure I would like to ask someone with a little more

By the way, I recognized another problem. The code also contains two
calls to "SetDIBits" with parameter "height" for "UINT lines". However
"height" may be negative. When I'm able to produce a patch for
Bug#13344 I will fix this as well.
Mathias Kosch <info at> |
RSA Public Key:

IT-Nachrichten auf heise online:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: modified-StretchDIBits.c
Type: application/octet-stream
Size: 6148 bytes
Desc: not available
Url : 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: output.txt

More information about the wine-devel mailing list