Wildert

I'm creating an app that has a large canvas, and the user can drop a grid ontop of the canvas for visual help if they want. Drawing the grid takes a while (5 seconds or more) on a fast computer, and it eats up a lot of ram (200 megs). I see applications like Excel, where I select the entire page and do a border fill, and its grid-drawing performance is leaps and bounds better, both in speed and ram. Am i pointlessly trying to compete with GDI, or can WPF perform this well



Re: Windows Presentation Foundation (WPF) best possible performance for drawing lines

Bragi

How are you drawing the grid I have done a similar exercise using a visual brush to accomplish the grid effect. Basically I drew 2 lines (1 horizontal, 1 vertical, you could also use a rect but than you have the borders touching each other) which I used as the Visual prop of the brush. If you tile the brush, you get a grid effect. I have implemented zooming by redrawing the 2 lines (which redraws the grid), this way there is no distortion in the pixel widht of the lines (I first tried a transform, which changes the thickness of the lines, something not desired in the grid). This technique is very fast and doesn't consume much memory.




Re: Windows Presentation Foundation (WPF) best possible performance for drawing lines

Tim Dawson

On the other hand, you are correct that you're never going to compete with GDI when it comes to drawing lines. Nowhere close.






Re: Windows Presentation Foundation (WPF) best possible performance for drawing lines

becko565

Tim Dawson wrote:
On the other hand, you are correct that you're never going to compete with GDI when it comes to drawing lines. Nowhere close.



So, is WPF doomed to have less performance than GDI Isn't WPF supposed to exploit the graphics hardware more than GDI




Re: Windows Presentation Foundation (WPF) best possible performance for drawing lines

Marco Zhou - MSFT

It depends on your scenario, generally speaking, DrawingVisual and StreamGeometry is the fast enough APIs for mere drawing operations.

Hope this helps