Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphics.DrawImage scaling method?

Tags:

c#

graphics

Given the following code:

    var target = new Bitmap(source.Size.Width / 2, source.Size.Height / 2);
    using (var g = Graphics.FromImage(target))
    {
        g.DrawImage(source, new Rectangle(Point.Empty, target.Size));
        g.Save();
        return target;
    }

What scaling method does 'DrawImage' use? Is it an average of 4 pixels? The value at {0,0)? Can I adjust this behaviour?

Thanks!

like image 263
Ian Newson Avatar asked Nov 24 '25 11:11

Ian Newson


1 Answers

You can set the value of the Graphics.InterpolationMode property to the interpolation method that you want to use. This must be done before you call DrawImage.

like image 122
JosephDaSilva Avatar answered Nov 25 '25 23:11

JosephDaSilva