怎样在上传的图片的时候打上logo

Duwamish 2004-12-10 10:02:23
不关上传的是ipg还是gif,
Img = System.Drawing.Image.FromStream(PostedFile.InputStream);
Graphics g= Graphics.FromImage(Img);
string logo="www.chinagemshop.com";
g.DrawString(logo, new Font("papyrus",15), new SolidBrush(Color.Gray), 5, -5);
...全文
169 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Duwamish 2004-12-10
  • 打赏
  • 举报
回复
楼上的说的是什么意思啊,我不太明白
kwork 2004-12-10
  • 打赏
  • 举报
回复
mark
Duwamish 2004-12-10
  • 打赏
  • 举报
回复
这样写不知道为什么不行
ybh2002 2004-12-10
  • 打赏
  • 举报
回复
动网有现在的程序。
qifanghcy 2004-12-10
  • 打赏
  • 举报
回复
给你一个示例方法:
/// <summary>
/// 生成版权水印图片.
/// </summary>
/// <param name="sourceFile">图片源文件完整路径及文件名</param>
public static void CreateCopyRightImage(string sourceFile)
{
try
{
if (!System.IO.File.Exists(sourceFile))
throw new Exception("图片文件" + sourceFile + "不存在!");

System.Drawing.Image image = System.Drawing.Image.FromFile(sourceFile);

int width = image.Width; //图片宽度
int height = image.Height; //图片高度

Graphics g = Graphics.FromImage(image);

//取得版权文字的长度及宽度
System.Drawing.SizeF sf = g.MeasureString(ImageCopyRightText,ImageCopyRightFont);

//写入版权文字的位置
PointF pf = new PointF(width - sf.Width - 20,height - sf.Height - 5);

g.DrawString(ImageCopyRightText,ImageCopyRightFont,new SolidBrush(ImageCopyRightColor),pf);
Bitmap bmp = new Bitmap(image);
bmp.Save(sourceFile + ".tmp",System.Drawing.Imaging.ImageFormat.Jpeg);

g.Dispose();
image.Dispose();
bmp.Dispose();

//删除原文件,并将临时文件拷贝成带版权的图片文件后删除临时文件
System.IO.File.Delete(sourceFile);
System.IO.File.Copy(sourceFile + ".tmp",sourceFile);
System.IO.File.Delete(sourceFile + ".tmp");
}
catch(Exception ex)
{
throw new Exception("生成版权信息水印失败!",ex);
}
}
CSTerry 2004-12-10
  • 打赏
  • 举报
回复
可以的,做完操作把Img另存就可以了
Duwamish 2004-12-10
  • 打赏
  • 举报
回复

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧