src/NetStandard/Drawing/Drawing/src/Extensions/Image.cs
/// <summary>
/// Resize the image to the specified width and height.
/// </summary>
/// <param name="image">The image to resize.</param>
/// <param name="width">The width to resize to.</param>
/// <param name="height">The height to resize to.</param>
/// <returns>The resized image.</returns>
Resize the image to the specified width and height.
Resize the image to the specified width and height .
public static Bitmap ResizeImage(this Image image, int width, int height)
        {
            var destRect = new Rectangle(0, 0, width, height);
            var destImage = new Bitmap(width, height);
            destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
            using (var graphics = Graphics.FromImage(destImage)) {
                graphics.CompositingMode = CompositingMode.SourceCopy;
                graphics.CompositingQuality = CompositingQuality.HighQuality;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                using var wrapMode = new ImageAttributes();
                wrapMode.SetWrapMode(WrapMode.TileFlipXY);
                graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
            }
            return destImage;
        }
public static Bitmap ResizeImage ( this Image image , int width , int height ) { var destRect = new Rectangle ( 0 , 0 , width , height ) ; var destImage = new Bitmap ( width , height ) ; destImage . SetResolution ( image . HorizontalResolution , image . VerticalResolution ) ; using ( var graphics = Graphics . FromImage ( destImage ) ) { graphics . CompositingMode = CompositingMode . SourceCopy ; graphics . CompositingQuality = CompositingQuality . HighQuality ; graphics . InterpolationMode = InterpolationMode . HighQualityBicubic ; graphics . SmoothingMode = SmoothingMode . HighQuality ; graphics . PixelOffsetMode = PixelOffsetMode . HighQuality ; using var wrapMode = new ImageAttributes ( ) ; wrapMode . SetWrapMode ( WrapMode . TileFlipXY ) ; graphics . DrawImage ( image , destRect , 0 , 0 , image . Width , image . Height , GraphicsUnit . Pixel , wrapMode ) ; } return destImage ; }
Resize the image to the specified width and height.
Resize the image to the specified width and height .
The resized image.
The resized image .
Image
this
<not_specific>
width
int
The width to resize to.
The width to resize to .
height
int
The height to resize to.
The height to resize to .
image
<not_specific>
The image to resize.
The image to resize .