gdiplus: When copying an image do not round pixel positions up.

Dmitry Timoshkov dmitry at baikal.ru
Tue Aug 28 03:58:24 CDT 2012


Vincent Povirk <madewokherd at gmail.com> wrote:

> >> I just did, and the behavior, though it looks wrong, is the same
> >> between builtin and native - the image is shifted by 1/2 pixel so that
> >> it's cut off at the upper-left and we have extra transparent space at
> >> the lower-right.
> >
> > With native gdiplus scenario described earlier works just fine for me,
> > while with built-in there are black borders on bottom/right.
> 
> You should be getting transparent borders on the bottom/right.
> 
> This probably means you're using a surface that's not capable of alpha
> blending, and in that situation gdi_alpha_blend currently draws fully
> transparent pixels as black when it shouldn't. I'm pretty sure I
> mentioned that as a problem earlier, around the time you introduced
> gdi_alpha_blend.

The problem is not related to a device not supporting alpha blending,
I even replaced a TRACE there by ERR just in case, but it never triggers.

> If you compare the size of the image drawn between native/builtin (not
> counting the border, which native draws as transparent, as does
> builtin under normal circumstances), I think you'll find that it
> currently matches and your patch changes it. If you didn't notice,
> you're probably not enlarging the image enough.

I don't see a difference in the image size regardless how much I enlarge
the image.

> Since GdipDrawImage doesn't accept a source rectangle, and those extra
> pixels are supposed to be transparent, you could probably have
> GdipDrawImage subtract 0.5 from your image width and height. That
> should solve your problem in this limited case without fixing
> gdi_alpha_blend or introducing a bug.

Subtracting 0.5 from width and height hides the problem, but that's
just a compensation to rounding up that my patch is removing.

-- 
Dmitry.



More information about the wine-devel mailing list