I want to display text as image using c#.net. And i am using following code.
int nWidth = 50, nHeight = 30;
GDI.Pen redPen = new GDI.Pen(GDI.Color.Red, 2);
GDI.Bitmap b1 = new GDI.Bitmap(nWidth, nHeight);
GDI.Graphics g1 = GDI.Graphics.FromImage(b1);
//String drawString = "طرف";
// Create font and brush.
GDI.Font drawFont = new GDI.Font("Nafees Nastaleeq(Updated)", 8f,GDI.FontStyle.Regular);
//GDI.Font drawFont = new GDI.Font("Times New Roman", 9);
GDI.SolidBrush drawBrush = new GDI.SolidBrush(GDI.Color.Black);
// Create point for upper-left corner of drawing.
float x = 25;
float y = 5;
// Set format of string.
GDI.StringFormat drawFormat = new GDI.StringFormat();
//drawFormat.FormatFlags = GDI.StringFormatFlags.direction;
//drawFormat.Alignment = System.Drawing.StringAlignment.Center;
// Draw string to screen.
//e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
g1.Clear(GDI.Color.White);
//g1.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
g1.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
g1.DrawString("Hello", drawFont, drawBrush, x, y, drawFormat);
g1.Flush();
It is working correctly but issue with me is that when it convert text in image, the text did not displayed correctly. so is there any solution that to get the quality result.
sh_alibz
Member
2 Points
41 Posts
Display text as image in c#.net
Aug 27, 2009 04:50 AM|LINK
Hi All,
I want to display text as image using c#.net. And i am using following code.
int nWidth = 50, nHeight = 30; GDI.Pen redPen = new GDI.Pen(GDI.Color.Red, 2); GDI.Bitmap b1 = new GDI.Bitmap(nWidth, nHeight); GDI.Graphics g1 = GDI.Graphics.FromImage(b1); //String drawString = "طرف"; // Create font and brush. GDI.Font drawFont = new GDI.Font("Nafees Nastaleeq(Updated)", 8f,GDI.FontStyle.Regular); //GDI.Font drawFont = new GDI.Font("Times New Roman", 9); GDI.SolidBrush drawBrush = new GDI.SolidBrush(GDI.Color.Black); // Create point for upper-left corner of drawing. float x = 25; float y = 5; // Set format of string. GDI.StringFormat drawFormat = new GDI.StringFormat(); //drawFormat.FormatFlags = GDI.StringFormatFlags.direction; //drawFormat.Alignment = System.Drawing.StringAlignment.Center; // Draw string to screen. //e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); g1.Clear(GDI.Color.White); //g1.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; g1.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; g1.DrawString("Hello", drawFont, drawBrush, x, y, drawFormat); g1.Flush();It is working correctly but issue with me is that when it convert text in image, the text did not displayed correctly. so is there any solution that to get the quality result.
Best Regards,
Ali bin zubair
setahamid
Participant
1299 Points
245 Posts
Re: Display text as image in c#.net
Aug 27, 2009 05:04 AM|LINK
Hi ,
Go through following Url .May that will help U .
http://www.codeproject.com/KB/aspnet/DynamicASPDotNETTextImage.aspx
Hamid Seta
http://www.hamidseta.blogspot.com/
Remember to click “Mark as Answer” on the post, if it helps you.
sh_alibz
Member
2 Points
41 Posts
Re: Display text as image in c#.net
Aug 27, 2009 05:27 AM|LINK
Thanks for reply. but it did not work for me. Below is the link of image which is required.
http://www.esnips.com/doc/27347c3a-4c10-4bc9-b641-c86786139255/new
And Below is the image which is generated with my program.
http://www.esnips.com/doc/03e94dae-43b4-41b9-8f26-54582aaf330e/Wife
So now it might be more clear about my requirement.
Regards,
Ali bin zubair