Tag: 裁剪图片

如何保存PictureBox上创建的图形?

在c#和Visual Studio Windows窗体中,我已将图像加载到图片框(pictureBox2)中,然后将其裁剪并显示在另一个图片框(pictureBox3)中。 现在我想将pictureBox3中的内容保存为图像文件。 我怎样才能做到这一点? private void crop_bttn_Click(object sender, EventArgs e) { Image crop = GetCopyImage(“grayScale.jpg”); pictureBox2.Image = crop; Bitmap sourceBitmap = new Bitmap(pictureBox2.Image, pictureBox2.Width, pictureBox2.Height); Graphics g = pictureBox3.CreateGraphics(); g.DrawImage(sourceBitmap, new Rectangle(0, 0, pictureBox3.Width, pictureBox3.Height), rectCropArea, GraphicsUnit.Pixel); sourceBitmap.Dispose(); }