/// <summary>
/// 在图片上生成图片水印
/// </summary>
/// <param name="Path">原服务器图片路径</param>
/// <param name="Path_syp">生成的带图片水印的图片路径</param>
/// <param name="Path_sypf">水印图片路径</param>
public static void AddShuiYinPic(string Path, string Path_sypf, string Path_syp, string addText)
{
float picTransparency = 0.7f;
float[][] nArray ={ new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, picTransparency, 0},
new float[] {0, 0, 0, 0, 1}};
System.Drawing.Imaging.ColorMatrix matrix = new System.Drawing.Imaging.ColorMatrix(nArray);
System.Drawing.Imaging.ImageAttributes attributes = new System.Drawing.Imaging.ImageAttributes();
attributes.SetColorMatrix(matrix, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap);
System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
g.DrawImage(copyImage, new System.Drawing.Rectangle(image.Width - copyImage.Width - 70, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel, attributes);
g.DrawImage(image, 0, 0, image.Width, image.Height);
float xpos = 0;
float ypos = 0;
Font crFont = null;
SizeF crSize = new SizeF();
int[] sizes = new int[] { 16, 14, 12, 10, 8, 6, 4 };
for (int i = 0; i < 7; i++)
{
crFont = new Font("Arial", sizes[i], FontStyle.Bold);
crSize = g.MeasureString(addText, crFont);
if ((ushort)crSize.Width < (ushort)image.Width)
break;
}
xpos = ((float)image.Width * (float).99) - (crSize.Width / 2);
ypos = ((float)image.Height * (float).99) - crSize.Height;
SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(153, 255, 255, 255));
StringFormat StrFormat = new StringFormat();
StrFormat.Alignment = StringAlignment.Center;
g.DrawString(addText, crFont, semiTransBrush, xpos, ypos, StrFormat);
image.Save(Path_syp);
g.Flush();
g.Dispose();
image.Dispose();
}
AddShuiYinPic(bigPicPath, @"D:\分站3\代码\NewSub\Css\images\top_logo.gif", bigPicPath_sy, DateTime.Now.Year.ToString());
if (File.Exists(bigPicPath))
{
File.Delete(bigPicPath); 在这里报错了,正由另一进程使用,因此该进程无法访问该文件。
}
巴比豆相册功能多:,超级搬家, 批量搞定你的店铺所有商品;
免费动态计数器统计:可以实现店铺浏览量; 每天来多少客源,轻松掌握;
宝贝模板:百余款模板免费用, 一键式到淘宝.非常方便!新手也能很快学会使用;
批量上传,批量下载.批量加水印,批量改大小, 批量帖图,防止图片被盗!
可以支持批量图片上传..也支持批量图片贴图到宝贝页面中..
如有题还可以随时联系在线客服为你解决疑难杂症.