3个回答
展开全部
public string GetCopyrightByImg(string path, string fileName, string Path_sypf)
{
FileInfo file = new FileInfo(path+fileName);
file.MoveTo(path + "diagram_" + fileName);
path = path.Replace("/", "\\");
string FileName = fileName;
if (File.Exists(path + FileName) == false)
{
System.Drawing.Image oldimage = System.Drawing.Image.FromFile(path + "diagram_" + fileName);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(oldimage);
g.DrawImage(copyImage, new System.Drawing.Rectangle(oldimage.Width - copyImage.Width-10,
oldimage.Height - copyImage.Height-10, copyImage.Width, copyImage.Height),
0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel);
string YFileName = FileName;
switch (FileName.Split(".".ToCharArray())[1].ToUpper())
{
case "JPEG":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case "JPG":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case "GIF":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Gif);
break;
case "PNG":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Png);
break;
case "BMP":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Bmp);
break;
default:
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
}
copyImage.Dispose();
g.Dispose();
oldimage.Dispose();
File.Delete(path + "diagram_" + fileName);
return YFileName;//返回处理后的图片名称
}
else//如果图片已经存在则返回""
{
return "";
}
}
{
FileInfo file = new FileInfo(path+fileName);
file.MoveTo(path + "diagram_" + fileName);
path = path.Replace("/", "\\");
string FileName = fileName;
if (File.Exists(path + FileName) == false)
{
System.Drawing.Image oldimage = System.Drawing.Image.FromFile(path + "diagram_" + fileName);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(oldimage);
g.DrawImage(copyImage, new System.Drawing.Rectangle(oldimage.Width - copyImage.Width-10,
oldimage.Height - copyImage.Height-10, copyImage.Width, copyImage.Height),
0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel);
string YFileName = FileName;
switch (FileName.Split(".".ToCharArray())[1].ToUpper())
{
case "JPEG":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case "JPG":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case "GIF":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Gif);
break;
case "PNG":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Png);
break;
case "BMP":
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Bmp);
break;
default:
oldimage.Save(path + YFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
}
copyImage.Dispose();
g.Dispose();
oldimage.Dispose();
File.Delete(path + "diagram_" + fileName);
return YFileName;//返回处理后的图片名称
}
else//如果图片已经存在则返回""
{
return "";
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
通过。net画板类库,在你的图片上会出自己水印。在这之前你会得到图片大小。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
文字水印还是图片水印?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询