Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GdipDrawImagePointsRect does not handle Graphics with a transformation. #728

Open
jhergens opened this issue Dec 6, 2021 · 0 comments
Open

Comments

@jhergens
Copy link

jhergens commented Dec 6, 2021

GdipDrawImagePointsRect does not take any existing transformation in the graphics object into account.

The following code:

var bitmap = new Bitmap(1000, 1000);
using (var graphics = Graphics.FromImage(bitmap))
{
    graphics.ScaleTransform(10, 10);
    graphics.Clear(Color.White);

    var redBitmap = new Bitmap(50, 50);
    using (var redGraphics = Graphics.FromImage(redBitmap))
    {
        redGraphics.Clear(Color.Red);
    }

    var destRect = new RectangleF(25, 25, 50, 50);
    var srcRect = new RectangleF(0, 0, 50, 50);

    PointF[] destRectanglePoints =
    {
        new(destRect.Left, destRect.Top),
        new(destRect.Right, destRect.Top),
        new(destRect.Left, destRect.Bottom)
    };

    // This one is broken.
    graphics.DrawImage(redBitmap, destRectanglePoints, srcRect, GraphicsUnit.Pixel);

    // This one works
    // graphics.DrawImage(redBitmap, destRect, srcRect, GraphicsUnit.Pixel);

    using (var pen = new Pen(Color.Black))
    {
        graphics.DrawRectangle(pen, new Rectangle(25, 25, 50, 50));
    }
}

Renders like this:
screenshot-3

It is expected to render like this:
screenshot-4

We are building libgdiplus from main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant