C# 图像裁剪

来源:百度知道 编辑:UC知道 时间:2024/06/30 09:56:04
我想用C#做图像的裁剪,希望高手帮我做个方法。要求:图片框pictureBox的图片bitmap,通过一个矩形框selectRec(这个我已经画出来了)裁剪出来,然后再显示再在片框pictureBox中。方法我想这样声明:
private Bitmap Crop(Bitmap bitmap)
{
}
谢谢各位了!

是不是这个意思
private void button1_Click(object sender, EventArgs e)
{
pictureBox2.Image = Crop((Bitmap)pictureBox1.Image);
}

private Bitmap Crop(Bitmap bitmap)
{
Rectangle rec = new Rectangle(10, 10, 50, 50);
return bitmap.Clone(rec,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
}

关注