JumpyNET
Well-known member
- Joined
- Apr 4, 2005
- Messages
- 151
Im 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 dont know how to accomplish this. Im also having problems positioning the text inside the circle. Note that the text width can change.
[VB]
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)
Lets draw a circle
GraphicObject.DrawEllipse(New Pen(Color.Blue, 5), CenterPoint.X, CenterPoint.Y, 50, 50)
Lets 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()
Lets update the picturebox
PictureBox1.Image = BitmapObject
GraphicObject.Dispose()
[/VB]
[VB]
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)
Lets draw a circle
GraphicObject.DrawEllipse(New Pen(Color.Blue, 5), CenterPoint.X, CenterPoint.Y, 50, 50)
Lets 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()
Lets update the picturebox
PictureBox1.Image = BitmapObject
GraphicObject.Dispose()
[/VB]
Last edited by a moderator: