PLavelle
asked on
GDI DrawEllipse on Bitmap - Ellipse cut off
The sides of the ellipse are getting cut off when I draw it to this image. Any ideas?
Dim oGraphics As Graphics = Nothing
Dim oFillBrush As SolidBrush = Nothing
Dim oBorderPen As Pen = Nothing
imgShape.Left = 0
imgShape.Top = 0
imgShape.Width = Me.Width
imgShape.Height = Me.Height
imgShape.Image = New Bitmap(imgShape.Width, imgShape.Height)
oGraphics = Graphics.FromImage(imgShap e.Image)
oGraphics.SmoothingMode = Drawing2D.SmoothingMode.An tiAlias
oFillBrush = New SolidBrush(Me.BackColor)
oBorderPen = New Pen(Me.LineColor, Me.LineWidth)
Dim iOffset As Int32 = 0
Dim oImageRect As New Rectangle(imgShape.ClientR ectangle.X + iOffset, imgShape.ClientRectangle.X + iOffset, imgShape.ClientRectangle.W idth - iOffset * 2, imgShape.ClientRectangle.H eight - iOffset * 2)
oGraphics.FillEllipse(oFil lBrush, oImageRect)
oGraphics.DrawEllipse(oBor derPen, oImageRect)
'Dispose of everything
Dim oGraphics As Graphics = Nothing
Dim oFillBrush As SolidBrush = Nothing
Dim oBorderPen As Pen = Nothing
imgShape.Left = 0
imgShape.Top = 0
imgShape.Width = Me.Width
imgShape.Height = Me.Height
imgShape.Image = New Bitmap(imgShape.Width, imgShape.Height)
oGraphics = Graphics.FromImage(imgShap
oGraphics.SmoothingMode = Drawing2D.SmoothingMode.An
oFillBrush = New SolidBrush(Me.BackColor)
oBorderPen = New Pen(Me.LineColor, Me.LineWidth)
Dim iOffset As Int32 = 0
Dim oImageRect As New Rectangle(imgShape.ClientR
oGraphics.FillEllipse(oFil
oGraphics.DrawEllipse(oBor
'Dispose of everything
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi, did this work for you ?
ASKER
Here's what worked:
Dim rcControl As New Rectangle(iLineWidth / 2, iLineWidth / 2, Me.Width - iLineWidth, Me.Height - iLineWidth)
Thanks for the help.
Dim rcControl As New Rectangle(iLineWidth / 2, iLineWidth / 2, Me.Width - iLineWidth, Me.Height - iLineWidth)
Thanks for the help.
Dim oImageRect As New Rectangle(imgShape.ClientR
maybe because you used imgshape.ClientRectangle.X
|
Here V
Dim oImageRect As New Rectangle(imgShape.ClientR
but anyways the clientRectangle property always returns a rectangle with x,y = 0,0
so to make your code right use it this way
Dim oImageRect As New Rectangle(iOffset, iOffset, imgShape.ClientRectangle.W