每次尝试将图片添加到图片框时,我都会记忆不足
我试过在它的开头做一个处理但是当我尝试从文件添加图像时它仍然只是让我内存不足
public void water(string path,string oupath)
{
pictureBox1.Image = Image.FromFile(path);
Font myfont = new Font("Times New Roman", 12.0f);
Graphics g = Graphics.FromImage(pictureBox1.Image);
// Calculate the size of the text
string waterString = waterText.Text;
SizeF sz = g.MeasureString(waterString, myfont);
// drawing position (X,Y)
Brush myBrush = new SolidBrush(Color.White);
int X;
int Y;
//Set the drawing position based on the users
//selection of placing the text at the bottom or top of the image
X = (int)(pictureBox1.Image.Width - sz.Width) / 2;
Y = (int)(pictureBox1.Image.Height - sz.Height);
// draw the water mark text
g.DrawString(waterString, myfont, myBrush, new Point(X, Y));
string filename = Path.GetFileName(path);
path = oupath+"/"+filename;
pictureBox1.Image.Save(@"path",ImageFormat.Jpeg);
pictureBox1.Image.Dispose();
}