Resize Bitmap - CSharp System.Drawing

CSharp examples for System.Drawing:Image Size

Description

Resize Bitmap

Demo Code

// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing;
using System.IO;// w  w w  .jav  a 2 s.c  om
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Collections;
using System.Configuration;
using System.Text;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data;
using System.Threading;
using System;

public class Main{
    public static Bitmap ResizeBitmap(Bitmap bmp, int width, int height)
      {
         Bitmap dst = new Bitmap(width, height, PixelFormat.Format24bppRgb);
         Graphics g = Graphics.FromImage(dst);
         g.SmoothingMode = SmoothingMode.HighQuality;
         g.InterpolationMode = InterpolationMode.HighQualityBicubic;

         Rectangle r = new Rectangle(0, 0, width, height);

         g.DrawImage(bmp, r);

         return dst;
      }
}

Related Tutorials