Bug in GDI whit zoom
From: Davide Rocchelli [ITA] ([ITA)
Date: 06/16/04
- Next message: vipin: "Re: SetPrinterDataEx directory services"
- Previous message: Mike D Sutton _at_ Work: "Re: how to decode the cubic Bezier spline data in TTPOLYCURVE struct?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 16 Jun 2004 06:27:01 -0700
I have found a probable bug when you draw with GDI.
Look this simple code
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Const Zoom As Single = 0.001
Dim p As Pen
'line incriminate
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
'clear
e.Graphics.Clear(Color.Black)
'zoom
e.Graphics.ScaleTransform(Zoom, Zoom)
'create a pen
p = New Pen(Color.Red, 1)
p.DashPattern = New Single() {5, 5}
'draw line (adjusted to zoom)
e.Graphics.DrawLine(p, (Me.ClientRectangle.Left / Zoom), (Me.ClientRectangle.Top / Zoom), (Me.ClientRectangle.Right / Zoom), (Me.ClientRectangle.Bottom / Zoom))
End Sub
If you set SmoothingMode to AntiAlias or HighQuality the line is ok: the dash pattern is what you want. But if you set SmoothingMode to another value, the pattern is oscene, idem if you set p.DashStyle = DashStyle.Dash (or other value except Solid) without use DashPattern. If yout don't use the zoom (ScaleTransform) you have no problem.
With personal Pattern you must do this to have the desired pattern
p.DashPattern = New Single() {5 / Zoom, 5 / Zoom}
but if you use this line with e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias (or HightQuality) the line's style is obsene.
The right action is with Drawing2D.SmoothingMode.AntiAlias: if I set thath i want a line, I want a line, not a trash 'cause i make a zoom ...
Suggestion ? I must calculate then pattern depending the quality, and this not good ...
Davide.
- Next message: vipin: "Re: SetPrinterDataEx directory services"
- Previous message: Mike D Sutton _at_ Work: "Re: how to decode the cubic Bezier spline data in TTPOLYCURVE struct?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|