Artemis.Utilities.ImageUtilities.ResizeImage C# (CSharp) Метод

ResizeImage() публичный статический Метод

Resize the image to the specified width and height.
public static ResizeImage ( Image image, int width, int height ) : Bitmap
image System.Drawing.Image The image to resize.
width int The width to resize to.
height int The height to resize to.
Результат System.Drawing.Bitmap
        public static Bitmap ResizeImage(Image image, int width, int height)
        {
            //a holder for the result
            var result = new Bitmap(width, height);
            //set the resolutions the same to avoid cropping due to resolution differences
            result.SetResolution(image.HorizontalResolution, image.VerticalResolution);

            //use a graphics object to draw the resized image into the bitmap
            using (var graphics = Graphics.FromImage(result))
            {
                //draw the image into the target bitmap
                graphics.DrawImage(image, 0, 0, result.Width, result.Height);
            }

            //return the resulting bitmap
            return result;
        }