using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
namespace bitmaprerote
{
public partial class suofang : Form
{
public suofang()
{
InitializeComponent();
}
/// <summary>
/// Resize图片
/// </summary>
/// <param name="bmp">原始Bitmap</param>
/// <param name="newW">新的宽度</param>
/// <param name="newH">新的高度</param>
/// <returns>处理以后的图片</returns>
public static Bitmap KiResizeImage(Bitmap bmp, int newW, int newH, int Mode)
{
try
{
Bitmap map = new Bitmap(newW, newH);
Graphics g = Graphics.FromImage(map);
// 插值算法的质量
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(bmp, new Rectangle(0, 0, newW, newH), new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
g.Dispose();
return map;
}
catch
{
return null;
}
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap map = new Bitmap("F:\\hj.jpg");
map = KiResizeImage(map, 90, 90, 20);
pictureBox1.Image = map;
}
}
}
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
namespace bitmaprerote
{
public partial class suofang : Form
{
public suofang()
{
InitializeComponent();
}
/// <summary>
/// Resize图片
/// </summary>
/// <param name="bmp">原始Bitmap</param>
/// <param name="newW">新的宽度</param>
/// <param name="newH">新的高度</param>
/// <returns>处理以后的图片</returns>
public static Bitmap KiResizeImage(Bitmap bmp, int newW, int newH, int Mode)
{
try
{
Bitmap map = new Bitmap(newW, newH);
Graphics g = Graphics.FromImage(map);
// 插值算法的质量
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(bmp, new Rectangle(0, 0, newW, newH), new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
g.Dispose();
return map;
}
catch
{
return null;
}
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap map = new Bitmap("F:\\hj.jpg");
map = KiResizeImage(map, 90, 90, 20);
pictureBox1.Image = map;
}
}
}