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); }
/// <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)); }