Re: Fast drawing of graphs
From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 04/03/04
- Next message: Joseph M. Newcomer: "Re: WinError.h"
- Previous message: Ohaya: "Adding member variable (CEdit control) for edit box causes Unhandled exception"
- In reply to: Bolek: "Fast drawing of graphs"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 02 Apr 2004 22:41:41 -0500
Actually, if you use MFC, it is equally trivial to draw on a background bitmap; you add a
few lines of code easily cribbed from any number of Web sites and it is all done.
A more serious question is how to truly optimize the drawing. One method I used was to
compute the scaled points and save the array (about 100,000 points). I then applied (as
another answer gives) PolyLine in MM_TEXT mode to this array. As I added more points, I
would set my scaling, compute the new LPtoDP and store the DPs. The result of this was
that updates (especially when scolling, which was terribly important) were real-time. But
the downside was if the user asked to "expand axis" I had to recompute all the points,
which took long enough to require a progress bar, but then again, I was using 133MHz
machines in those days. By prescaling, I eliminated the lengthy scaling computation on
every point, and that made a difference. (Resizing the windows in the Y-direction also
required a recomputaiton, but the nature of the analysis task was that the user usually
used full-screen displays with splitter windows and never resized the windows, and only
occasionally rescaled the x-axis for magnification)
joe
On Thu, 01 Apr 2004 13:16:08 +0200, Bolek <kraljaprvni@volny.cz> wrote:
>Hello,
>
>I programmed a class that draws an x-y graph on a CStatic window. I used
>CClientDC for the CStatic window.
>
>If the graph has severel tens points, it is sufficiently fast. However,
>the graph may contain up to several tens thousand points and then the
>routine is very slow - about half a second or more. How can I make my
>routine faster? When I used Borland C++ Builder, this culd be easily
>achieved by not drawing directly on the, but drawing to a hidden bitmap
>and then displaying the whole bitmap at once. However I don't know how
>to do it in MSVC6.
>
>Thanks.
>
>Bolek
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
- Next message: Joseph M. Newcomer: "Re: WinError.h"
- Previous message: Ohaya: "Adding member variable (CEdit control) for edit box causes Unhandled exception"
- In reply to: Bolek: "Fast drawing of graphs"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|