<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>System.Drawing/GDI+</title><link>http://forums.asp.net/150.aspx</link><description>Discuss manipulating and creating graphics using the System.Drawing namespace and GDI+.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: how to use System.Drawing.Graphics.MeasureString?</title><link>http://forums.asp.net/thread/3258199.aspx</link><pubDate>Thu, 25 Jun 2009 15:56:29 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3258199</guid><dc:creator>SGWellens</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3258199.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=150&amp;PostID=3258199</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Here is a sample:&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;    /// ---- TextToBitmap ----------------------------
    ///
    /// using System.Drawing;
    /// using System.Drawing.Imaging;
    /// Author: Steve Wellens
    /// 
    /// &amp;lt;summary&amp;gt;
    /// Takes a Text string and returns a bitmap of the string
    /// &amp;lt;/summary&amp;gt;

    public static Bitmap TextToBitmap(String TheText)
    {
        Font DrawFont = null;
        SolidBrush DrawBrush = null;
        Graphics DrawGraphics = null;
        Bitmap TextBitmap = null;
        try
        {
            // start with empty bitmap, get it&amp;#39;s graphic&amp;#39;s object
            // and choose a font
            TextBitmap = new Bitmap(1, 1);
            DrawGraphics = Graphics.FromImage(TextBitmap);
            DrawFont = new Font(&amp;quot;Arial&amp;quot;, 16);

            // see how big the text will be
            int Width = (int)DrawGraphics.MeasureString(TheText, DrawFont).Width;
            int Height = (int)DrawGraphics.MeasureString(TheText, DrawFont).Height;

            // recreate the bitmap and graphic object with the new size
            TextBitmap = new Bitmap(TextBitmap, Width, Height);
            DrawGraphics = Graphics.FromImage(TextBitmap);

            // get the drawing brush and where we&amp;#39;re going to draw
            DrawBrush = new SolidBrush(Color.Black);
            PointF DrawPoint = new PointF(0, 0);

            // clear the graphic white and draw the string
            DrawGraphics.Clear(Color.White);
            DrawGraphics.DrawString(TheText, DrawFont, DrawBrush, DrawPoint);

            return TextBitmap;
        }
        finally
        {
            // don&amp;#39;t dispose the bitmap, the caller needs it.
            DrawFont.Dispose();
            DrawBrush.Dispose();
            DrawGraphics.Dispose();
        }
    }
&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>how to use System.Drawing.Graphics.MeasureString?</title><link>http://forums.asp.net/thread/3258185.aspx</link><pubDate>Thu, 25 Jun 2009 15:49:55 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3258185</guid><dc:creator>Inx</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3258185.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=150&amp;PostID=3258185</wfw:commentRss><description>&lt;p&gt;Hi!&lt;/p&gt;&lt;p&gt;Im need to get the width of a string..but I cant realy figure out how to use this method...Im currently doing the following..&lt;/p&gt;&lt;p&gt;System.Drawing.Graphics.MeasureString(lnkBtnMenuObjectMiddle[i].Text, lnkBtnMenuObjectMiddle[i].Font).Width;&lt;/p&gt;&lt;p&gt;but it wont work...&lt;/p&gt;&lt;p&gt;any ideas?&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>