Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try setting the <code>InterpolationMode</code> of the graphics object to some value such as <code>HighQualityBicubic</code>. This should ensure that resize/scaled image looks much better than the "default".</p> <p>So, in the code you have posted, instead of doing:</p> <pre><code>// Create new Bitmap at new dimensions Bitmap result = new Bitmap((int)newWidth, (int)newHeight); using (Graphics g = Graphics.FromImage((System.Drawing.Image)result)) g.DrawImage(src, 0, 0, (int)newWidth, (int)newHeight); return result; </code></pre> <p>Try doing this instead:</p> <pre><code>// Create new Bitmap at new dimensions Bitmap result = new Bitmap((int)newWidth, (int)newHeight); using (Graphics g = Graphics.FromImage((System.Drawing.Image)result)) { g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(src, 0, 0, (int)newWidth, (int)newHeight); } return result; </code></pre> <p>(Note the line setting the <code>InterpolationMode</code> property to one of the InterpolationMode enumeration's values).</p> <p>Please see this link:<br> <a href="http://msdn.microsoft.com/en-us/library/k0fsyd4e.aspx" rel="nofollow noreferrer">How to: Use Interpolation Mode to Control Image Quality During Scaling</a><br> For further information on controlling the quality of an image when resizing/scaling.</p> <p>Also see this CodeProject article:<br> <a href="http://www.codeproject.com/KB/GDI-plus/imageresize.aspx" rel="nofollow noreferrer">Resizing a Photographic image with GDI+ for .NET</a><br> For information of the different visual effects the various InterpolationMode enumeration settings will have on an image. (About two-thirds of the way down the article, under the section entitled, "One last thing...").</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload