How to render text in Directwrite? [duplicate]
Possible Duplicate:
Is th开发者_如何学Goere any way to render text into DirectWrite????
Hello, all is it possible to render text in Directwrite and save it as png image using ASP.NET C# for my web application. IF YES please HELP. Thanks
I dont know if you its That what you mean but try this.
Bitmap bitmap = new Bitmap(100, 100);
Graphics g = Graphics.FromImage(bitmap);
g.DrawString("HALLO", new Font("Arial", 12), Brushes.Black, new PointF(10, 10));
bitmap.Save(<Put Filestream here>);
i don't know more about DirectWrite but if you have got the string value you need to render you can render it easy
void fun()
{
int width = 220, height = 115;
int xPosition=5,yPosition=5;
Image m = new Bitmap(width,height);
Graphics gx = Graphics.FromImage(m);
gx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
gx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
gx.DrawString("Hello Wrold", new System.Drawing.Font("tahoma", 12.0f), Brushes.Black, xPosition, yPosition);
m.Save(@"d:\myimage.png",ImageFormat.Png);
}
精彩评论