给图片加水印 但保存后 为什么图片没有水印 请高手帮忙看看

[复制链接]
查看11 | 回复3 | 2011-3-25 02:42:07 | 显示全部楼层 |阅读模式
private void button2_Click(object sender, EventArgs e)

{

Image image = Image.FromFile(\"F:\\\\my\\\\1.jpg\");


Bitmap b = new Bitmap(image.Width, image.Height,

PixelFormat.Format24bppRgb);


Graphics g = Graphics.FromImage(b);



g.DrawImage(image, 0, 0, image.Width, image.Height);

this.addWatermarkText(g, \"我是小王子\",image.Width,image.Height);


b.Save(\"F:\\\\my\\\\ttt.jpg\");

b.Dispose();

image.Dispose();





}





private void addWatermarkText(Graphics picture, string _watermarkText,

int _width, int _height)

{

// 确定水印文字的字体大小


Font crFont = null;

SizeF crSize = new SizeF();

crFont = new Font(\"Arial Black\",30, FontStyle.Bold);

crSize = picture.MeasureString(_watermarkText, crFont);




// 生成水印图片(将文字写到图片中)

Bitmap floatBmp = new Bitmap((int)crSize.Width 3,

(int)crSize.Height 3, PixelFormat.Format32bppArgb);

Graphics fg = Graphics.FromImage(floatBmp);

PointF pt = new PointF(40, 300);





// 画文字

fg.DrawString(_watermarkText,

crFont, new SolidBrush(Color.Red),

pt.X, pt.Y);


// 保存刚才的操作

fg.Save();

fg.Dispose();



}
回复

使用道具 举报

千问 | 2011-3-25 02:42:07 | 显示全部楼层
<pre id=\"best-answer-content\" class=\"reply-text mb10\">private void addWatermarkText(Graphics picture, string _watermarkText,

int _width, int _height)

{

// 确定水印文字的字体大小


Font crFont = null;

SizeF crSize = new SizeF();

crFont = new Font(\"Arial Black\",30, FontStyle.Bold);

crSize = picture.MeasureString(_watermarkText, crFont);


// 生成水印图片(将文字写到图片中)

PointF pt = new PointF(40, 300);

// 画文字

picture.DrawString(_watermarkText,

crFont, new SolidBrush(Color.Red),

pt.X, pt.Y);


// 保存刚才的操作

fg.Save();

fg.Dispose();

}

















<h4 class=\"ask\">追问





<pre class=\"replyask-text\" id=\"content-2600758\">你改哪里了啊
回复

使用道具 举报

千问 | 2011-3-25 02:42:07 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-2600805\">你对比一下,看看
回复

使用道具 举报

千问 | 2011-3-25 02:42:07 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-2601885\">还是不行啊 就是改动后的图片没水印啊是没加上吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行