Re: Pen width difficult to control with scaled graphics



This is a well known problem with GDI+

There doesn't seem to be a workaround except drawing some of the graphics at scale and then others unscaled using the matrix but scaled manually.



--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Paul" <this@xxxxxxxxxx> wrote in message news:%23g0akn0XJHA.5828@xxxxxxxxxxxxxxxxxxxxxxx
I'm using System.Drawing.

My logical drawing area is 10000f x 10000f. I am drawing a graph of
continuous meter readings using Graphics.DrawLines. How can you set a pen
width of 4 pixels? I am completely baffled. Either I get 1 pixel width or
it snaps up to about 50 pixels. There is no fine control over the pen
width. I am inverting the pen scaling using the inverse of the graphics
transform (required for constant width lines).

The funny thing is that when my logical units are 10000f x 100f I can
control the pen width very nicely, and by inverting the graphics transform
the line drawn is uniform in x and y directions, which is what you would
want. I would use this scaling, but there is some strange rounding error
and my curves have annoying step jumps -- I am using float valued APIs and
I was expecting all my win32 rounding issues a thing of the past. By
increasing the vertical scale by x100 I get smooth curves, but the pen is
out of control then.

Did any of this make sense?

.



Relevant Pages

  • The story: Painting bitmap to screen is slow
    ... I've done a lot graphics programming by now and the thing that bothers me with GDI+ in .NET framework the most is slow drawing of bitmaps to screen. ... In Win32, there were two types of bitmaps, compatible and memory bitmap. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: The story: Painting bitmap to screen is slow
    ... The general "trick" behind great GDI+ performance is to do all drawing ... single bitmap to the screen. ... I heard Microsoft broke GDI acceleration for some operations in Vista. ... your configuration of Vista or graphics driver. ...
    (microsoft.public.dotnet.framework.drawing)
  • How to do some GDI on top of Direct3D
    ... Does anybody have experience with GDI on top of Direct3D on Pocket PC? ... ImageAttributes to set transparent color and when I finish drawing I draw ... bitmap to the graphics. ... I know that I could use Sprite to render bitmap, ...
    (microsoft.public.win32.programmer.directx.managed)
  • DirectDraw vs GDI
    ... I am writing an application with eVC++ 4.2 that does a lot of graphics ... benefits to be gained from getting DDraw installed onto the system? ... drawing of simple primitives like lines, rectangles and text be improved if ... DDraw was used instead of the GDI? ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: /boot/loader graphics support & extensibility
    ... and drawing filled rectangles (e.g. to clear the screen ... and different graphics hardware supports ... The Forth code calls the rectangle function. ... what will be the bitmap format of the temporary ...
    (freebsd-hackers)