Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I'm using the following code to draw a rotated string inside a circle to a picture box. Any ideas how I could make the picture quality better for the text? I was thinking something like making it first bigger and then smaller - but don't know how to accomplish this. I'm also having problems positioning the text inside the circle. Note that the text width can change.

 

       'This function will draw a circle with rotated text inside it.

       'This should be the centerpoint of the text and circle
       Dim CenterPoint As System.Drawing.Point = New System.Drawing.Point(20, 60)

       'Declarations
       Dim GraphicObject As Graphics
       Dim BitmapObject As Bitmap
       BitmapObject = New Bitmap(PictureBox1.Width, PictureBox1.Height, PictureBox1.CreateGraphics)
       GraphicObject = Graphics.FromImage(BitmapObject)

       'Let's draw a circle
       GraphicObject.DrawEllipse(New Pen(Color.Blue, 5), CenterPoint.X, CenterPoint.Y, 50, 50)

       'Let's draw rotated text inside the circle
       GraphicObject.TranslateTransform(CenterPoint.X, CenterPoint.Y)
       GraphicObject.RotateTransform(-45.0F)
       GraphicObject.DrawString("hh:mm:ss:ms", New Font("Arial", 8, FontStyle.Regular), Brushes.Red, 0.0F, 0.0F)
       GraphicObject.ResetTransform()

       'Let's update the picturebox
       PictureBox1.Image = BitmapObject
       GraphicObject.Dispose()

Edited by JumpyNET
  • Leaders
Posted
Set the Hinting (might be TextHinting or something like that) property of the graphics object. There should be an option for anti-aliasing, an option for clear-type, and an option for aliased. That should help with the quality.
[sIGPIC]e[/sIGPIC]
Posted
Set the Hinting (might be TextHinting or something like that) property of the graphics object. There should be an option for anti-aliasing' date=' an option for clear-type, and an option for aliased. That should help with the quality.[/quote']

 

Thank you! I found the setting:

GraphicObject.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias

Never thought it could be that easy.

 

 

PS: I'm still strugling with that the text centering.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...