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

Mathias Kosch info at mkosch.de
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 3.4.1.1" 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
experience.

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 mkosch.de> | http://www.mkosch.de/
RSA Public Key: http://www.mkosch.de/pubkey

IT-Nachrichten auf heise online: http://www.heise.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: modified-StretchDIBits.c
Type: application/octet-stream
Size: 6148 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20080719/510857d7/attachment.obj 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: output.txt
Url: http://www.winehq.org/pipermail/wine-devel/attachments/20080719/510857d7/attachment.txt 


More information about the wine-devel mailing list