将裁剪的图像(在另一个图片框中显示为图形)保存在本地

时间:2016-08-30 15:18:11

标签: c# image winforms visual-studio crop

这就是场景,假设我有两个图片盒。 pbSrc 显示源图像, pbCrop 显示裁剪后的图像。我的代码显示了从 pbSrc pbCrop 的裁剪图像。我试着保存它,但输出并不像我期望的那样:(((

pbCrop.Refresh();

//Prepare a new Bitmap on which the cropped image will be drawn
Bitmap sourceBitmap = new Bitmap(pbSrc.Image, pbSrc.Width, pbSrc.Height);
Graphics a = pbCrop.CreateGraphics();

//Draw the image on the Graphics object with the new dimesions
a.DrawImage(sourceBitmap, new Rectangle(0, 0, pbCrop.Width, pbCrop.Height), rectCropArea, GraphicsUnit.Pixel);
a.Save();  //Not sure if this really does saves the image into a file :v

0 个答案:

没有答案