首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

很奇怪,生成图片的高难度有关问题,欢迎进来讨论

2012-01-09 
很奇怪,生成图片的高难度问题,欢迎各位高手进来讨论!将flash设计的作品生成图片(用XML导出所有信息),但是

很奇怪,生成图片的高难度问题,欢迎各位高手进来讨论!
将flash设计的作品生成图片(用XML导出所有信息),但是生成图片的时候,却出现了很奇怪的问题:
    1,如果文字是粗体,斜体,带下划线其中的一种,则正常!
    2,如果文字是粗体又是带下划线,也正常,粗体也是斜体也正常
    3,如果是斜体带下划线,或者粗体,斜体,下划线都是的话,则生成的图片是仅带下划线,或者粗体下划线,即:斜体的属性没有了
    4,同样的文件,生成PDF没有问题;
    生成图片程序如下:
private   void   buildWordI(XmlNode   wordNode,   Graphics   g)
        {
                /*
                  *   <font= "null "  
                  *   y= "511 "  
                  *   x= "515 "  
                  *   size= "12 "  
                  *   leading= "0 "
                  *   letterSpacing= "0 "
                  *   align= "left "  
                  *   italic= "false "
                  *   underline= "false "  
                  *   bold= "false "  
                  *   text= "在此输入内容 "   />
                */
                string   font   =   wordNode.Attributes[ "font "].Value.ToString();
                int   size   =   int.Parse(wordNode.Attributes[ "size "].Value);
                string   italic   =   wordNode.Attributes[ "italic "].Value.ToString();
                string   underline   =   wordNode.Attributes[ "underline "].Value.ToString();
                string   bold   =   wordNode.Attributes[ "bold "].Value.ToString();
                string   align   =   wordNode.Attributes[ "align "].Value.ToString();
                string   text   =   wordNode.Attributes[ "text "].Value.ToString();
                int   color   =   int.Parse(wordNode.Attributes[ "color "].Value);
                float   x   =   float.Parse(wordNode.Attributes[ "x "].Value);
                float   y   =   float.Parse(wordNode.Attributes[ "y "].Value);
                float   width   =   float.Parse(wordNode.Attributes[ "width "].Value)   +   200;
                float   height   =   float.Parse(wordNode.Attributes[ "height "].Value);
                //
                string[]   texts;


                //
                texts   =   Regex.Split(text,   "\r ",   RegexOptions.IgnoreCase);
                //字体
                System.Drawing.Font   f   =   new   System.Drawing.Font(font,   size,   GraphicsUnit.Pixel);
                System.Drawing.Font   fb   =   new   System.Drawing.Font(f,   System.Drawing.FontStyle.Bold);
                System.Drawing.Font   fi   =   new   System.Drawing.Font(f,   System.Drawing.FontStyle.Italic);
                System.Drawing.Font   fu   =   new   System.Drawing.Font(f,   System.Drawing.FontStyle.Underline);
                System.Drawing.Font   fbi   =   new   System.Drawing.Font(fb,   System.Drawing.FontStyle.Italic);
                System.Drawing.Font   fiu   =   new   System.Drawing.Font(fi,   System.Drawing.FontStyle.Underline);
                System.Drawing.Font   fub   =   new   System.Drawing.Font(fu,   System.Drawing.FontStyle.Bold);
                System.Drawing.Font   fbiu   =   new   System.Drawing.Font(fbi,   System.Drawing.FontStyle.Underline);
                System.Drawing.Font   ff;
                if   (bold   ==   "true ")
                {
                        if   (italic   ==   "true ")
                        {
                                if   (underline   ==   "true ")
                                {
                                        ff   =   fbiu;
                                }
                                else
                                {
                                        ff   =   fbi;
                                }
                        }
                        else   if   (underline   ==   "true ")
                        {
                                ff   =   fub;


                        }
                        else
                        {
                                ff   =   fb;
                        }
                }
                else   if   (italic   ==   "true ")
                {
                        if   (underline   ==   "true ")
                        {
                                ff   =   fiu;
                        }
                        else
                        {
                                ff   =   fi;
                        }
                }
                else   if   (underline   ==   "true ")
                {
                        ff   =   fu;
                }
                else
                {
                        ff   =   f;
                }
                //字体颜色
                System.Drawing.Color   c   =   System.Drawing.Color.FromArgb(color);
                System.Drawing.Brush   b   =   new   System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255,   c));
                //样式  
                System.Drawing.StringFormat   sf   =   new   System.Drawing.StringFormat();
                sf.FormatFlags   =   System.Drawing.StringFormatFlags.FitBlackBox;
                if   (align   ==   "left ")
                {
                        sf.Alignment   =   System.Drawing.StringAlignment.Near;
                }
                else   if   (align   ==   "center ")


                {
                        sf.Alignment   =   System.Drawing.StringAlignment.Center;
                }
                else   if   (align   ==   "right ")
                {
                        sf.Alignment   =   System.Drawing.StringAlignment.Far;
                }
                System.Drawing.PointF   pf   =   new   System.Drawing.PointF(x,   y);
                for   (int   i   =   0;   i   <   texts.Length;   ++i)
                {
                        if   (align   ==   "left ")
                        {
                                g.DrawString(texts[i],   ff,   b,   new   System.Drawing.RectangleF(x,   y   +   (i   *   height   /   texts.Length),   width,   height   /   texts.Length),   sf);
                        }
                        else   if   (align   ==   "center ")
                        {
                                g.DrawString(texts[i],   ff,   b,   new   System.Drawing.RectangleF(x   -   100,   y   +   (i   *   height   /   texts.Length),   width,   height   /   texts.Length),   sf);

                        }
                        else   if   (align   ==   "right ")
                        {
                                g.DrawString(texts[i],   ff,   b,   new   System.Drawing.RectangleF(x   -   200,   y   +   (i   *   height   /   texts.Length),   width,   height   /   texts.Length),   sf);
                        }

                }
        }

          高手们,考验你们的时候到了,帮帮忙吧!多谢大家的参与!!

[解决办法]
沙发
[解决办法]
没搞过!帮顶!
[解决办法]
帮顶
------解决方案--------------------


只能再次让你失望的顶拉。。。

热点排行