怎么给GIF格式的图片添加水印!"?
使用下面代码并不能在gif文件添加水印(只能JPG那些)
/////////////////////////////
/////////////////////////////
private void Btn_Upload_Click(object sender, System.EventArgs e)
{
if(UploadFile.PostedFile.FileName.Trim()!="")
{
//上传文件
string extension = Path.GetExtension(UploadFile.PostedFile.FileName).ToUpper();
string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
string path = Server.MapPath(".") + "/UploadFile/" + fileName + extension;
UploadFile.PostedFile.SaveAs(path);
//加文字水印,注意,这里的代码和以下加图片水印的代码不能共存
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
Graphics g = Graphics.FromImage(image);
g.DrawImage(image, 0, 0, image.Width, image.Height);
Font f = new Font("Verdana", 32);
Brush b = new SolidBrush(Color.White);
string addText = AddText.Value.Trim();
g.DrawString(addText, f, b, 10, 10);
g.Dispose();
//加图片水印
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile( Server.MapPath(".") + "/Alex.gif");
Graphics g = Graphics.FromImage(image);
g.DrawImage(copyImage, new Rectangle(image.Width-copyImage.Width, image.Height-copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, GraphicsUnit.Pixel);
g.Dispose();
//保存加水印过后的图片,删除原始图片
string newPath = Server.MapPath(".") + "/UploadFile/" + fileName + "_new" + extension;
image.Save(newPath);
image.Dispose();
if(File.Exists(path))
{
File.Delete(path);
}
Response.Redirect(newPath);
}
}
/////////////////////////////////////////
提示"无法从带有索引像素格式的图像创建 Graphics 对象"
问题点数:20、回复次数:11Top
1 楼singlepine(小山)回复于 2006-03-04 16:40:46 得分 0
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=209255Top
2 楼dreams1981(子山)回复于 2006-03-04 16:47:34 得分 0
不是一样的吗?Top
3 楼dreams1981(子山)回复于 2006-03-04 16:50:44 得分 0
完全一样的代码啊!只个对GIF的图片会提示"无法从带有索引像素格式的图像创建 Graphics 对象"
Top
4 楼BillTuan()回复于 2006-03-04 16:56:14 得分 0
记号!Top
5 楼dreams1981(子山)回复于 2006-03-04 17:19:25 得分 0
有办法吗?Top
6 楼dreams1981(子山)回复于 2006-03-06 09:01:46 得分 0
又放了几天了!Top
7 楼LGame(JGame)回复于 2006-03-06 09:23:41 得分 0
帮顶的人来了
要不你先转个格式~~~
??
把后辍名改了可以吗?Top
8 楼dreams1981(子山)回复于 2006-03-06 10:27:51 得分 0
改名那可以
!!!Top
9 楼dreams1981(子山)回复于 2006-03-06 11:03:49 得分 0
那位发段WEB的代码给我参考一下!谢谢了1Top
10 楼daiming(小蔚)回复于 2006-03-06 11:32:46 得分 0
用www.wave12.com的动画组件wsAniGIF2.6可以加 而且效果也不错
昨天一个网友刚推荐的Top
11 楼dreams1981(子山)回复于 2006-03-06 17:21:26 得分 0
唉~~!Top




