我在生成水印的时候水印文字老是按图片比例走,怎么才能让水印文字固定大小,下面是代码private void DoUpload(string filename1)
{
string path = Server.MapPath(".") + "/temp/" + filename1;
UploadFile.PostedFile.SaveAs(path);
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
Graphics g = Graphics.FromImage(image);
g.DrawImage(image, 0, 0, image.Width, image.Height);
Font f = new Font("Impact",9);
Brush b = new SolidBrush(Color.White);
string addText = "http://www.cn-solar.net";
g.DrawString(addText, f, b, 10, 10);
g.Dispose();
string newPath = Server.MapPath(".") + "/big/" + filename1;
image.Save(newPath);
image.Dispose();
if(File.Exists(path))
{
File.Delete(path);
}
}
{
string path = Server.MapPath(".") + "/temp/" + filename1;
UploadFile.PostedFile.SaveAs(path);
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
Graphics g = Graphics.FromImage(image);
g.DrawImage(image, 0, 0, image.Width, image.Height);
Font f = new Font("Impact",9);
Brush b = new SolidBrush(Color.White);
string addText = "http://www.cn-solar.net";
g.DrawString(addText, f, b, 10, 10);
g.Dispose();
string newPath = Server.MapPath(".") + "/big/" + filename1;
image.Save(newPath);
image.Dispose();
if(File.Exists(path))
{
File.Delete(path);
}
}
解决方案 »
- 大家早
- 求教 DataGridView的绑定dataTable增、删、改记录的我问题
- 读取TreeView内容写到Xml。
- MSHTMl命名空间在哪里啊?
- 关于正确表达式,,解决了马上给分,
- 如何控制上传图片的大小(急!!!!)
- web下拉菜单的实现问题!谢谢大家!希望有源码!谢谢!!!!!!
- 急,如何判断客户端的浏览器是不是支持cookies,不支持能修改它支持cookies吗
- 想问下在C#的winform中是可以用webBrower和htmlDcoment来获取页面上JS执行后的网页源码,但是在。net里网页应该怎么做呢
- 求助 一个简单的C++方法 翻译成 C# 谢谢大家
- vs2005C#的登陆窗口问题?
- 紧急请教!excel导入数据,只有一条数据时,某一列的值总是无法读取?多条数据就没有问题。。。
原样重画一遍是什么意思?另:没必要保存到文件,可以直接从流得到Image
Bitmap bm = new Bitmap(srcImage,newWidth, newHeight)
再用g来画注:Bitmap继承自Image
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
改为:
System.Drawing.Image image = System.Drawing.Image.FromStream(UploadFile.PostedFile.InputStream);