When rendering an image where either the width or height of the source and destination rectangles are the same, no scaling will occur even if the rectangles differ in the other dimension.
The following code:
var bitmap = new Bitmap(100, 200);
using (var graphics = Graphics.FromImage(bitmap))
{
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, 150);
var srcRect = new RectangleF(0, 0, 50, 50);
graphics.DrawImage(redBitmap, destRect, srcRect, GraphicsUnit.Pixel);
using (var pen = new Pen(Color.Black))
{
graphics.DrawRectangle(pen, Rectangle.Round(destRect));
}
}
Renders like this:
It is expected to render like this:
We are building libgdiplus from main.
It seems the problem is the following snippet in GdipDrawImageRectRect
When rendering an image where either the width or height of the source and destination rectangles are the same, no scaling will occur even if the rectangles differ in the other dimension.
The following code:
Renders like this:![image-1](https://user-images.githubusercontent.com/7846682/144900608-4ccd1035-5117-4a9f-8ca5-fe23e0d43a5d.png)
It is expected to render like this:![image-2](https://user-images.githubusercontent.com/7846682/144900662-6145847e-a669-45f3-9b8e-6238ab98ca5b.png)
We are building libgdiplus from main.
It seems the problem is the following snippet in GdipDrawImageRectRect
Changing && to || fixes this.