Ejemplo n.º 1
0
        protected override Bitmap DoStrImgConvert(StrImgConvertWrap wrap)
        {
            //н¨»æ»­Í¼Ïñ
            Bitmap map = new Bitmap(wrap.size.Width, wrap.size.Height);

            //·ÖÎöRtf´®»ñµÃ
            ParseRtfString(wrap.str);
            //¼ÆËã»æ»­ÐÅÏ¢
            CalcRtfDrawingInfo(m_rtfFormatList, wrap.size);
            //Ö´Ðл滭²Ù×÷
            using (Graphics grap = Graphics.FromImage(map))
            {
                //ÇåÆÁ£¬ÒÔ°×ɫΪµ×
                grap.Clear(Color.White);
                //»æÖÆ×Ö·û
                foreach (RtfFormat format in m_rtfFormatList)
                {
                    grap.DrawString(format.content, format.font, Brushes.Black, format.px, format.py);
                }
            }
            //ÊÍ·Å×ÖÌåÐÅÏ¢
            m_superSubFont.Dispose();
            m_font.Dispose();
            //·µ»ØͼÏñ
            return(map);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 实现StrImgCStrategy中的DoStrImgConvert
 /// </summary>
 /// <param name="str"></param>
 /// <returns></returns>
 protected override Bitmap DoStrImgConvert(StrImgConvertWrap wrap)
 {
     //重现RTF视图
     if (wrap.str.StartsWith(RtfEncoding.RtfFlag))
     {
         tempRichBox.Rtf = wrap.str;
     }
     else
     {
         tempRichBox.SelectedText = wrap.str;
     }
     //生成图像
     return(Format2Image(tempRichBox, wrap.size));
 }