如何保存PictureBox控件为JPEG文件,它的编辑后, [英] How to save a picturebox control as a jpeg file after it's edited
本文介绍了如何保存PictureBox控件为JPEG文件,它的编辑后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个图片框
在我的Windows窗体应用程序。
I have a PictureBox
on my Windows Forms application.
我加载在它的照片,我已经启用了油漆
事件在我的code。它绘制一个矩形。
I load a picture in it and I have enabled the Paint
event in my code. It draws a rectangle.
这样的:
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics gr = e.Graphics;
Pen p = new Pen(Color.Red);
p.Width = 5.0f;
gr.DrawRectangle(p, 1, 2, 30, 40);
}
和我点击保存按钮:
private void button2_Click(object sender, EventArgs e)
{
pictureBox1.Image.Save(@"C:\Documents and Settings\tr1g3800\Desktop\WALKING\30P\100000test.jpg",ImageFormat.Jpeg);
}
但保存的文件从来没有包含我画的矩形。
But the saved file never contains the rectangle that I drew.
没有人有任何想法?
推荐答案
您或许不应该直接对图片框绘制。
You probably shouldn't draw directly on the PictureBox.
您需要使用位图来代替。尝试把位图中PictureBox.Image,然后调用保存()。
You need to use a Bitmap instead. Try putting the bitmap in the PictureBox.Image and then call Save().
检查这个了解更多详细信息
这篇关于如何保存PictureBox控件为JPEG文件,它的编辑后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文