随笔-3  评论-7  文章-40  trackbacks-1

无法从带有索引像素格式的图像创建 Graphics 对象

先转位图,将原图像画到位图上,再保存位图
protected void AddWater(string originalImage, string waterTextPictureName)
    {
        string addText = "gogolike.com";
        System.Drawing.Image image = System.Drawing.Image.FromFile(originalImage);

        System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(image.Width, image.Height);

        System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);

        g.DrawImage(image, 0, 0, image.Width, image.Height);
        System.Drawing.Font f = new System.Drawing.Font("Verdana", 60);
       
        System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Green);

       

        try
        {
            g.DrawString(addText, f, b, 35, 35);
         
            bitmap.Save(waterTextPictureName);
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;
            throw ex;
        }
        finally
        {

            f.Dispose();
            b.Dispose();
            bitmap.Dispose();
            g.Dispose();
            image.Dispose();
        }
    }
0
0
(请您对文章做出评价)
« 上一篇:ArcIMS9.2 安装(windows server 2003 sp2+iis6)
» 下一篇:SQL Server 不允许进行远程连接 解决办法
posted on 2007-12-25 10:08 品茶 阅读(839) 评论(1)  编辑 收藏 所属分类: C#.NET

评论:
#1楼 2009-01-03 16:14 | 三角猫      
解决方案,建议看看下面:

http://www.zu14.cn/2008/12/19/net_gif_index_error/

  回复  引用  查看