locked
Some problem remains. Can anyone help??? RRS feed

  • Question

  • User1009273304 posted
    i have a textbox in which i write in bangla(Bengali). but when i try to convert the bangla text into a GIF file the image of character shows ????? or something like a box. By the way i used AVRO Bangla typing software. it is free to download. 

    <!-- CODE -->
    Code:
    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Text; using System.Drawing; using System.Drawing.Imaging; using System.Drawing.Text; using System.Drawing.Drawing2D; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void TextBox4_TextChanged1(object sender, EventArgs e) { string s = TextBox4.Text; System.Console.WriteLine(s); } protected void Button4_Click(object sender, EventArgs e) { string infotext = null; string text = TextBox4.Text;//Request.Form.Get("text"); int textLength = text.Length; int fontSize = 14; int orientation = 1; int antialias = 1; int width; int height; width = (fontSize * textLength) - ((textLength * fontSize) / 3); height = fontSize + 20; infotext=text; //Byte[] sourceBytes = Encoding.GetEncoding("utf-8").GetBytes(infotext); //Byte[] strbytes = Encoding.Convert(Encoding.GetEncoding(57003),Encod ing.Unicode, sourceBytes); //infotext = Encoding.Unicode.GetString(strbytes); //text = infotext; // Initialize graphics RectangleF rectF = new RectangleF(0, 0, width, height); Bitmap pic = new Bitmap(width, height, PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(pic); g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.AntiAlias; // Set colors string fgColor = "Black"; string bgColor = "White"; Color fontColor = Color.FromName(fgColor); Color rectColor = Color.FromName(bgColor); SolidBrush fgBrush = new SolidBrush(fontColor); SolidBrush bgBrush = new SolidBrush(rectColor); // Rectangle int bound = 1; g.FillRectangle(bgBrush, rectF); // Load font string fontName = "SUTOE___" + ".ttf";// this is bangla font file PrivateFontCollection privateFontCollection = new PrivateFontCollection(); privateFontCollection.AddFontFile(Server.MapPath("./") + fontName); FontFamily fontFamily = privateFontCollection.Families[0]; // Set font style FontStyle style = FontStyle.Regular; Font font = new Font(fontFamily, fontSize, style, GraphicsUnit.Pixel); // Set font direction & alignment StringFormat format = new StringFormat(); int alignment = 1; if (alignment == 1) { format.Alignment = StringAlignment.Near; } format.LineAlignment = StringAlignment.Center; // Finally, draw the font g.DrawString(text, font, fgBrush, rectF, format); pic.Save(Server.MapPath("~/generated_image.gif"),ImageFormat.Gif); } protected void Button1_Click(object sender, EventArgs e) { string s = TextBox4.Text; System.Console.WriteLine(s); } }
    Wednesday, February 28, 2007 10:36 PM

Answers

All replies

  • User113421904 posted

    I found the following in your code, so I'm wondering if the original input is Unicode?

          //Byte[] sourceBytes = Encoding.GetEncoding("utf-8").GetBytes(infotext);
          //Byte[] strbytes = Encoding.Convert(Encoding.GetEncoding(57003),Encod  ing.Unicode, sourceBytes);
          //infotext = Encoding.Unicode.GetString(strbytes);
          //text = infotext;

    Tuesday, March 6, 2007 8:35 AM
  • User113421904 posted

    I found a new thread: http://forums.asp.net/thread/1599822.aspx

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 6, 2007 8:53 AM