Hallo,
ich habe ein Doublebuffered Panel erstellt, auf dem ich mit der Maus per mousepath zeichnen kann.
Dies funktioniert auch.
Nun sind die gezeichneten Linien nicht sehr sauber, sondern haben kleinere Pixel Fehler.
In OneNote z.B. werden diese Pixelfehler nicht angezeigt, bzw. dort wird sauber gezeichnet.
Wie bekomme ich dies ebenso hin?
Ich habe 2 Anhänge angehangen, in der man den Unterschied erkennt.
Hier mein Code:
Spoiler anzeigen
ich habe ein Doublebuffered Panel erstellt, auf dem ich mit der Maus per mousepath zeichnen kann.
Dies funktioniert auch.
Nun sind die gezeichneten Linien nicht sehr sauber, sondern haben kleinere Pixel Fehler.
In OneNote z.B. werden diese Pixelfehler nicht angezeigt, bzw. dort wird sauber gezeichnet.
Wie bekomme ich dies ebenso hin?
Ich habe 2 Anhänge angehangen, in der man den Unterschied erkennt.
Hier mein Code:
VB.NET-Quellcode
- Private Sub pbSignature_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles pbSignature.MouseDown
- If e.Button = MouseButtons.Left Then ' draw a filled circle if left mouse is down
- mousePathMieter.StartFigure() ' The L mouse is down so we need to start a new line in mousePath
- End If
- End Sub
- Private Sub pbSignature_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles pbSignature.MouseMove
- If e.Button = MouseButtons.Left Then ' draw a filled circle if left mouse is down
- Try
- mousePathMieter.AddLine(e.X, e.Y, e.X, e.Y) 'Add mouse coordiantes to mousePath
- Catch
- MsgBox("No way, Hose!")
- End Try
- End If
- pbSignature.Invalidate() 'Repaint the PictureBox using the PictureBox1 Paint event
- End Sub
- Private Sub pbSignature_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles pbSignature.Paint
- Try
- If clearSign Then
- clearSign = False
- e.Graphics.Clear(Color.White)
- mousePathMieter.Reset()
- Else
- myUserColor = (System.Drawing.Color.Black) 'You can remove this line and add a user selected color to
- 'change the value of myUserColor
- e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
- e.Graphics.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
- e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
- myAlpha = 255 ' This will give the color a Alpha effect, you can set this to 255 if you want a full color
- '*********************** NOTE ***********************************************
- 'The line below set the pen up with the ability to add user selected Alpha, Color and Penwidth
- ' A simpler, but less flexible solution would be to replace the line with the following code:
- 'Dim CurrentPen = New Pen(System.Drawing.Color.Black, myPenWidth)
- '************ End Note ***************************
- Dim CurrentPen = New Pen(Color.FromArgb(myAlpha, myUserColor), myPenWidth) 'Set up the pen
- e.Graphics.DrawPath(CurrentPen, mousePathMieter) 'draw the path! :)
- End If
- Catch
- ' MsgBox("Not happening!")
- End Try
- End Sub