Hello,
I'm using GDI+ to create a graph.
I can have about 20,000 points and want to make a curve out of this points.
I iterated each point and used DrawLine to draw each line and it was really slow.
I found that with:
graphPath.AddLines(test) 'test is an array of points
grfx.DrawPath(pluma, graphPath)
I can make ir really fast... but the thing is that the pen I'm using only displays the EndCap for the whole path (only at the end) and not for each of the lines that create that path.
I want to show where each point is located with pluma.EndCap = RoundAnchor...it worked well with DrawLine... but with the path I get the EndCap only at the end of the path... I used AddEllipse for each point but it's very very slow.
How can I do that Is it possible

How do you add EndCap AnchorCircle to each line in a Path
davidy13
Kish_UNI
Thank you Peter.
I'm getting closer... I just tried LineJoin but it only smoothes the connection of the lines on each point (in case I use a line width grater than 1.. I'm using pluma.width=1)...
but what I want is to have a circle in each connection that is wider than the line... like when you use EndCap=RoundAnchor on lines.
Is there anything like LineJoin but that you can put a circle,square,diamond... anything on each connection
I want to do something like when you do a Chart in Excel and choose Line with markers displayed at each data value.
Tejas34
Thank you Peter,
I tried that too... I called SetMarkers() after each AddLine and it's doing the same... actually, I found that AddLine is almost as slow as DrawLine ... so.. I'm just going to keep the DrawLine...
I'm using stopWatch.Start() and stopWatch.Elapsed to check the time is taking to do the refresh.
Using DrawLine iterating each one it takes 2.80 seconds
Using a Path and AddLine one by one... it takes about 1.90 seconds
Using DrawLines(test) ... iterating first to construct the test array and the drawing it takes 0.12 seconds ... but I can't use EndCap for each segment...
Using a Path and AddLines(test) to a path and then displaying the path takes about 0.18 seconds... Can't use EndCap either...
The problem is... every time the user selects a menu that hides part of the graph... I have to repaint... and the computer freezes for 2.80 seconds... it's really annoying.
I'm wondering... is there a way that I can "save" the graph so that when I need to repaint, it only repaints whatever was before... instead of drawing line by line again .. I tried to use grfx.Save and grfx.Restore... but it doesn't save pixel data...actually I don't know what this methods do... in VB6 I just had the AutoRedraw = Yes and thats it... now.. I have to redraw everything ... am I right
If the user resizes the window... he'll have to wait the 2.8 seconds...since I have to recalculate the graph segments...but that's ok... it's not that annoying...
Thank you for your help.
GP-BLR
You could try using the Metafile class to group a bunch of drawing primitives together for "playback" (see the Graphics.EnumerateMetafile method). You can use a MemoryStream object to avoid having to use a physical file with Metafile.
I don't know off hand what, if any, performance improvements you'd get using a Metafile instead of DrawLine repeatedly.
hommer
Let me know if that works.
Michael Wittenburg