By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,948 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,948 IT Pros & Developers. It's quick & easy.

BUG in GDI whit zoom ?

P: n/a
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.
Nov 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.