/// <summary> /// Draws art text with center point and black box /// </summary> private static void DrawArtTextWithMarkup(ArtText text, Graphics graphics) { // Draw round text, its black box and center point graphics.DrawText(text); graphics.DrawRectangle(new Pen(RgbColor.Gray, 1f), text.GetBlackBox()); graphics.FillEllipse(new SolidBrush(RgbColor.Red), text.Center.X - 3, text.Center.Y - 3, 6, 6); }
static Stream BuildTextImage(string strText, Color color, int nWidth = 400) { // 文字图片 return(ArtText.BuildArtText( strText, "Consolas", // "Microsoft YaHei", (float)16, FontStyle.Bold, color, Color.Transparent, Color.Gray, ArtEffect.None, ImageFormat.Png, nWidth)); }
// 文字图片 public static MemoryStream TextImage( ImageFormat image_format, string strText, System.Drawing.Color text_color, System.Drawing.Color back_color, float fFontSize = 10, int nWidth = 300) { return(ArtText.BuildArtText( strText, "Microsoft YaHei", fFontSize, FontStyle.Regular, text_color, back_color, Color.Gray, ArtEffect.None, image_format, nWidth)); }
void OutputLogo(string strFileName, string strText) { FileInfo fi = new FileInfo(strFileName); DateTime lastmodified = fi.LastWriteTimeUtc; this.Response.AddHeader("Last-Modified", DateTimeUtil.Rfc1123DateTimeString(lastmodified)); // .ToUniversalTime() TextInfo info = new TextInfo(); info.FontFace = "Microsoft YaHei"; info.FontSize = 10; info.colorText = Color.Gray; // 文字图片 using (MemoryStream image = ArtText.PaintText( strFileName, strText, info, "center", "100%", "100%", "65%", ImageFormat.Jpeg)) { this.Response.ContentType = "image/jpeg"; this.Response.AddHeader("Content-Length", image.Length.ToString()); //this.Response.AddHeader("Pragma", "no-cache"); //this.Response.AddHeader("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); //this.Response.AddHeader("Expires", "0"); FlushOutput flushdelegate = new FlushOutput(MyFlushOutput); image.Seek(0, SeekOrigin.Begin); StreamUtil.DumpStream(image, Response.OutputStream, flushdelegate); } // Response.Flush(); Response.End(); }