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));
}
}
GdipDrawImagePointsRect does not take any existing transformation in the graphics object into account.
The following code:
Renders like this:
It is expected to render like this:
We are building libgdiplus from main.