我想用另一個jpg圖像水印一個jpg圖像。如果將結果圖像存儲爲新圖像,它工作正常。是否可以用水印圖像更新原始圖像文件?我不需要將它作爲一個不同的文件存儲。C#中的水印jpg文件
這裏是我的代碼:
//watermark image
Bitmap sizedImg = (Bitmap)System.Drawing.Image.FromFile(@"C:\report branding.jpg");
//original file
System.Drawing.Bitmap template=(System.Drawing.Bitmap)System.Drawing.Image.FromFile(@"C:\CentralUtahCombined1.jpg");
Graphics g = Graphics.FromImage(template);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.DrawImage(sizedImg, new Point(template.Width - sizedImg.Width,
template.Height - sizedImg.Height));
//watermarking the image but saving it as a different image file - here if I //provide the name as the original file name, it throws an error
string myFilename = @"C:\CentralUtah.jpg";
template.Save(myFilename);
template.Dispose();
sizedImg.Dispose();
g.Flush();
什麼是拋出的異常? – 2013-03-19 23:29:33