CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2002
    Posts
    87

    DrawString function

    Dear code gurus,

    I am using a "DrawString" function to display text in bitmap. For whatever reason, the text displayed have some "shading" as on the picture below. In this picture I have used Arial 20pt regular font and "Black" brush. You may not see the problem due to the size of the picture, but if you "blow it up" you will see that different shades are used to draw the text.
    Name:  CodeGuru.jpg
Views: 1032
Size:  2.9 KB

    What am I doing wrong? What should I fix to display the text only in black on my bitmap, no additional colors.

    Thank you for your help.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: DrawString function

    Quote Originally Posted by balexei View Post
    What am I doing wrong?
    What are you doing? Without a code snippet, it's going to be hard to help you.

  3. #3
    Join Date
    Jan 2002
    Posts
    87

    Re: DrawString function

    Arjay,

    Sorry, below is my code:
    Code:
    public Bitmap BitmapForLabel(string Text, Font mFont, Point p, int w, int h)
            {
                Bitmap MyLabel = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format16bppRgb555);
                Graphics myGraphics = Graphics.FromImage(MyLabel);
                Brush myBrush = new SolidBrush(Color.Black);
    
                myGraphics.DrawString(Text, mFont, myBrush, p);
    
                return MyLabel;
            }

  4. #4
    Join Date
    Jan 2009
    Posts
    596

    Re: DrawString function

    This is just anti-aliasing. You can control how text is rendered using the Graphics.TextRenderingHint property

  5. #5
    Join Date
    Jan 2002
    Posts
    87

    Re: DrawString function

    Quote Originally Posted by Peter_B View Post
    This is just anti-aliasing. You can control how text is rendered using the Graphics.TextRenderingHint property
    Thank you very much!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured