Potential bug in dash pattern

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

For custom dash patterns, the device space lines drawn depend on (from the documentation)

1. Pattern specification (float[])
2. Transform (scale etc.)
3. Pen width

I have noticed that the line pattern is also affected by the following two, but I can't seem to get coherent results, or find anything in the documentation

4. Alpha blending
5. Quality smoothing.

Both alpha and antialiasing will modify the dash pattern, is this a bug?

Regards

Anders Forsgren
 
Hi Anders,

I'm not clear which document you refers to, could you give a link to this
doc? Also from your description, the AlphaBlending and smoothing affects
the dash pattern drawn on the screen, could you give more description about
the differences in effects between using alpha blending/Smoothing or not,
it would be better if you could give some screen captures to show this
difference.
I'll try to confirm this issue with product group after getting more detail
info from you.

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Hi Anders,
I'm not clear which document you refers to, could you give a link to this
doc? Also from your description, the AlphaBlending and smoothing affects
the dash pattern drawn on the screen, could you give more description about
the differences in effects between using alpha blending/Smoothing or not,
it would be better if you could give some screen captures to show this
difference.
I'll try to confirm this issue with product group after getting more detail
info from you.

The dash patterns scale with the Pen width, which is explained for example here:
http://msdn.microsoft.com/library/d...awlinesandshapes/drawingacustomdashedline.asp

The fact that the dash pattern (in screen space) also scales with scale transform is natural.
I'll try to produce some code/screenshots and send to your microsoft email address.

To reproduce the behavior I'm describing do the following:

-Get a graphics object to draw on (normal smoothing mode)
-Change the scale transform of the graphics to something other than 1.0
-Create a custom dash pattern
-Create a pen with this dash pattern and a solid color, pen width=1
-Draw a line on the graphics surface using the pen
-Create another pen with a width of 5, and the same dash pattern with all elements divided by 5, i.e. {5, 10, 1} is now {1, 2, 0.2}.

What you will see now is the correct behavior, The two lines, one thin and one thick have the same dash lengths, since we corrected for the line width. So far so good.

To reproduce the odd behavior:

-Repeat the above steps with a non-solid color (i.e. alpha value of e.g. 128), or using a graphics object with smoothing enabled. The 2 lines will now have different dash lengths (the compensation for pen width will not work now, it seems one must also compensate for alpha and antialias somehow).

Thanks for any pointers

Regards,
Anders Forsgren
 
Hello Anders,

I reproduced your problem in the VG.net designer. When you add smoothing,
the 0-width lines no longer scale the dash pattern according to the current
transformation. So when you zoom in or out, the pattern remains the same,
when it should get larger or smaller.

One way to fix it, and make the thin line consistent with the thick one, is
to set the line width to 1. But now, the line becomes thicker as you zoom
in.

You can do a double compensation: for the 1 pixel line, set the line width
equal to the inverse of your current scaling. This will guarantee a one
pixel line. Now multiply all the custom dash pattern values by the current
scaling, to compensate for the width change. In your example, at a scale of
4 in x and y dimensions,
- line width set to .25
- dash pattern set to 20, 40, 4, 4

Now the smoothed line looks like the non-smoothed one: 1 pixel wide, with
the same dash pattern.

The VG.net designer makes it easy to experiment with GDI+ this way without
writing code.

Regards,
Frank Hileman

check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor

Anders Forsgren said:
The dash patterns scale with the Pen width, which is explained for example here:
http://msdn.microsoft.com/library/d...awlinesandshapes/drawingacustomdashedline.asp

The fact that the dash pattern (in screen space) also scales with scale transform is natural.
I'll try to produce some code/screenshots and send to your microsoft email address.

To reproduce the behavior I'm describing do the following:

-Get a graphics object to draw on (normal smoothing mode)
-Change the scale transform of the graphics to something other than 1.0
-Create a custom dash pattern
-Create a pen with this dash pattern and a solid color, pen width=1
-Draw a line on the graphics surface using the pen
-Create another pen with a width of 5, and the same dash pattern with all
elements divided by 5, i.e. {5, 10, 1} is now {1, 2, 0.2}.
What you will see now is the correct behavior, The two lines, one thin and
one thick have the same dash lengths, since we corrected for the line width.
So far so good.
To reproduce the odd behavior:

-Repeat the above steps with a non-solid color (i.e. alpha value of e.g.
128), or using a graphics object with smoothing enabled. The 2 lines will
now have different dash lengths (the compensation for pen width will not
work now, it seems one must also compensate for alpha and antialias
somehow).
 
Hi Anders,

I apologize for the late reply.
Product group is still investigating this issue.
We appreciate your patience while we are researching on it.

I'll update this thread as soon as I get reply from product group.
If you have any conerns or updates on this issue please feel free to let me
know!

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Hi Anders,

I apologize for the long delay, current the product group is still
investigating this issue. I'll update this thread and send you a
notification mail as soon as I got the reply from product group.

Thanks for your patience and understanding.


By the way, Was frank's suggestion helpful to your problem?

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Hi Anders,

Thanks for bringing this to our attention. I've filed a bug against Windows
(GDI+) for this behavior.

I presume the workaround suggested by Frank will allow you to get past this
issue. Please let me know if that's not the case.

Thanks,
- John
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.


The dash patterns scale with the Pen width, which is explained for example here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIP
lus/usingGDIPlus/usingapentodrawlinesandshapes/drawingacustomdashedline.asp

The fact that the dash pattern (in screen space) also scales with scale transform is natural.
I'll try to produce some code/screenshots and send to your microsoft email address.

To reproduce the behavior I'm describing do the following:

-Get a graphics object to draw on (normal smoothing mode)
-Change the scale transform of the graphics to something other than 1.0
-Create a custom dash pattern
-Create a pen with this dash pattern and a solid color, pen width=1
-Draw a line on the graphics surface using the pen
-Create another pen with a width of 5, and the same dash pattern with all
elements divided by 5, i.e. {5, 10, 1} is now {1, 2, 0.2}.
What you will see now is the correct behavior, The two lines, one thin
and one thick have the same dash lengths, since we corrected for the line
width. So far so good.
To reproduce the odd behavior:

-Repeat the above steps with a non-solid color (i.e. alpha value of e.g.
128), or using a graphics object with smoothing enabled. The 2 lines will
now have different dash lengths (the compensation for pen width will not
work now, it seems one must also compensate for alpha and antialias
somehow).
 
Back
Top