Hello.
I'm having a quality issue while using the ButtonRenderer to draw a button. Really what I need is only HALF of the button, so I figured I could create an image (Bitmap) draw the button to it, and then draw the required half of the bitmap to my control. There are some quality issues that are very noticeable while the button is in the PRESSED state - that are not there when using the control's graphics object being passed to the ButtonRenderer.
Here's a piece of example code that will show what I've described:
This results in the following:
Column 1 shows the button drawn directly to the PictureBox's graphics object (as obtained from the eventargs), and column 2 shows the button drawn first to a bitmap and then the picturebox. The 3 row (pressed state) is the one that shows the quality issue the clearest - you can see the top corners are not nicely rounded when drawn to the bitmap first.
As far as I can figure I need to draw to the bitmap first so I can grab only the part of the button I actually need to display.
Anyone know how to resolve the quality issues I'm having with the bitmap drawing?
Thanks.
I'm having a quality issue while using the ButtonRenderer to draw a button. Really what I need is only HALF of the button, so I figured I could create an image (Bitmap) draw the button to it, and then draw the required half of the bitmap to my control. There are some quality issues that are very noticeable while the button is in the PRESSED state - that are not there when using the control's graphics object being passed to the ButtonRenderer.
Here's a piece of example code that will show what I've described:
Code:
Private Sub pbox_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pbox.Paint
Dim lft As Integer = 15
Dim top As Integer = 15
For i As Integer = 1 To 5
Dim btnBounds As New Rectangle(lft, top, 75, 23)
ButtonRenderer.DrawButton(e.Graphics, btnBounds, i)
top += 28
Next
top = 15
lft += 80
For i As Integer = 1 To 5
Dim bmp As New Bitmap(75, 23)
Dim g As Graphics = Graphics.FromImage(bmp)
ButtonRenderer.DrawButton(g, New Rectangle(0, 0, 75, 23), i)
g.Dispose()
e.Graphics.DrawImage(bmp, lft, top)
top += 28
Next
End Sub
This results in the following:
Column 1 shows the button drawn directly to the PictureBox's graphics object (as obtained from the eventargs), and column 2 shows the button drawn first to a bitmap and then the picturebox. The 3 row (pressed state) is the one that shows the quality issue the clearest - you can see the top corners are not nicely rounded when drawn to the bitmap first.
As far as I can figure I need to draw to the bitmap first so I can grab only the part of the button I actually need to display.
Anyone know how to resolve the quality issues I'm having with the bitmap drawing?
Thanks.