static void addWatermarkText(Graphics picture,int fontsize, string _watermarkText, string _watermarkPosition, int _width, int _height)
{
int[] sizes = new int[] {32, 14, 12, 10, 8, 6, 4 };
Font crFont = null;
SizeF crSize = new SizeF();
crFont = new Font("微软雅黑", fontsize, FontStyle.Bold);
crSize = picture.MeasureString(_watermarkText, crFont);
float xpos = 0;
float ypos = 0;
Color color =Color.Firebrick;
switch (_watermarkPosition)
{
case "WM_TOP_LEFT":
xpos = ((float)_width * (float).01) + (crSize.Width / 2);
ypos = (float)_height * (float).01;
break;
case "WM_TOP_RIGHT":
xpos = ((float)_width * (float).99) - (crSize.Width / 2);
ypos = (float)_height * (float).01;
break;
case "WM_BOTTOM_RIGHT":
xpos = ((float)_width * (float).99) - (crSize.Width / 2);
ypos = ((float)_height * (float).99) - crSize.Height;
break;
case "WM_BOTTOM_LEFT":
xpos = ((float)_width * (float).01) + (crSize.Width / 2);
ypos = ((float)_height * (float).99) - crSize.Height;
break;
}
StringFormat StrFormat = new StringFormat();
StrFormat.Alignment = StringAlignment.Center;
SolidBrush semiTransBrush2 = new SolidBrush(Color.FromArgb(153, 0, 0, 0));//加阴影
picture.DrawString(_watermarkText, crFont, semiTransBrush2, xpos + 1, ypos + 1, StrFormat);
SolidBrush semiTransBrush = new SolidBrush(color); //添加水印
picture.DrawString(_watermarkText, crFont, semiTransBrush, xpos, ypos, StrFormat);
semiTransBrush2.Dispose();
semiTransBrush.Dispose();
}
static void addWatermarkText(Graphics picture,string type, int fontsize, string _watermarkText)
{
//1、先画矩形
RectangleF drawRect;
Color color;
if (type == "Top")
{
drawRect = new RectangleF(73, 135, 450, 64);
color = Color.FromArgb(255, 255, 255);
}
else
{
drawRect = new RectangleF(194, 245, 250, 39);
color = Color.FromArgb(244, 226, 38);
}
//2、在基于矩形画水印文字
Font crFont = null;
StringFormat StrFormat = new StringFormat();
StrFormat.Alignment = StringAlignment.Center;
crFont = new Font("微软雅黑", fontsize, FontStyle.Bold);
SolidBrush semiTransBrush = new SolidBrush(color); //添加水印
picture.DrawString(_watermarkText, crFont, semiTransBrush, drawRect, StrFormat);
semiTransBrush.Dispose();
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有