Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to convert multiline textbox text to image

how to convert multiline textbox text to image

Scheduled Pinned Locked Moved ASP.NET
graphicssysadminhelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shuaib wasif khan
    wrote on last edited by
    #1

    hello sir ' my problem is that i am trying to convert multiline textbox text to gif format. every thing works fine except the text which is to be converted convert only first line . i think it is converting text box text as a single line any suggestion plz here is my code Bitmap b = new Bitmap(330,TextBox1.Text.Length, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(b); string message; g.Clear(Color.Yellow); message = TextBox1.Text; StringFormat format = new StringFormat(); int alignment = 1; if (alignment == 1) { format.Alignment = StringAlignment.Near; } format.LineAlignment = StringAlignment.Center; g.DrawString(TextBox1.Text, new Font("Kruti Dev 010", 12, FontStyle.Regular), new SolidBrush(Color.Black),new PointF(2.5F,.5F) ,format); Response.ContentType = "image/gif"; b.Save(Server.MapPath("IMG\\"+img+".gif"), ImageFormat.Gif); b.Dispose(); Response.Write("file uploaded Successfully"); }

    C 1 Reply Last reply
    0
    • S Shuaib wasif khan

      hello sir ' my problem is that i am trying to convert multiline textbox text to gif format. every thing works fine except the text which is to be converted convert only first line . i think it is converting text box text as a single line any suggestion plz here is my code Bitmap b = new Bitmap(330,TextBox1.Text.Length, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(b); string message; g.Clear(Color.Yellow); message = TextBox1.Text; StringFormat format = new StringFormat(); int alignment = 1; if (alignment == 1) { format.Alignment = StringAlignment.Near; } format.LineAlignment = StringAlignment.Center; g.DrawString(TextBox1.Text, new Font("Kruti Dev 010", 12, FontStyle.Regular), new SolidBrush(Color.Black),new PointF(2.5F,.5F) ,format); Response.ContentType = "image/gif"; b.Save(Server.MapPath("IMG\\"+img+".gif"), ImageFormat.Gif); b.Dispose(); Response.Write("file uploaded Successfully"); }

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      monu_khan wrote:

      TextBox1.Text.Length

      This is more than a little insane. You need to use MeasureString to get a width and height.

      monu_khan wrote:

      Graphics g = Graphics.FromImage(b);

      Why not use a using statement, instead of leaking resources ?

      monu_khan wrote:

      new Font("Kruti Dev 010", 12, FontStyle.Regular)

      Another leak, plus if you change the font, it means you need to measure the string for that font. Although you're using ASP.NET, this question has nothing to do with ASP.NET, it's about some basic graphics work. Why do you waste server space by saving a string a a bitmap instead of as text ?

      monu_khan wrote:

      int alignment = 1; if (alignment == 1)

      Bizarre.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups