Board index » delphi » Graphics and prventing full repaints...

Graphics and prventing full repaints...

I'm working on a small program to allow the user to draw over the top of a map
to find the length of a route for running/cycling/walking etc...  The problem
that I've got involves the way that repaints are handled.

At the moment I'm using a stack of 2 tImages. The bottom image stores the map
and the top handles user-actions (adding waypoints and the like.) The problem
arises in that whenever something happens in the top image the entire stack is
redrawn (panel, base image, top image) in full. This is extremely time-consuming
and leads to a large amount of flicker.

Has anyone got any pointers as to how I can get around this, preferably without
the need to delve into the GDI. If I am going to _have_ to use direct API calls
then if someone can point me at a simple tutorial on this sort of thing then I'd
be really grateful...

        thanks,

        Adam...

--
=====================================================================
Adam Fleming
Yr 4 MEng - Software Engineering (Aberystwyth)
Email: a...@aber.ac.uk
Web: http://www.aber.ac.uk/~ajf4
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Never underestimate the power of human stupidity - R.A.Heinlein
=====================================================================

 

Re:Graphics and prventing full repaints...


Quote
Adam Fleming wrote:

> I'm working on a small program to allow the user to draw over the top of a map
> to find the length of a route for running/cycling/walking etc...  The problem
> that I've got involves the way that repaints are handled.

> At the moment I'm using a stack of 2 tImages. The bottom image stores the map
> and the top handles user-actions (adding waypoints and the like.) The problem
> arises in that whenever something happens in the top image the entire stack is
> redrawn (panel, base image, top image) in full. This is extremely time-consuming
> and leads to a large amount of flicker.

        Use a paintbox and an offscreen TBitmap. Give the paintbox a one-line
OnPaint event handler

with Sender as TPaintbox do
begin
  Canvas.Draw(0,0,TheOffscreenBitmap);
end;

Now draw whatever you want on the bitmap (probably storing the bottom image
in a second bitmap and using it to modify the main one) - any time you've
modified the bitmap and want to refresh the paintbox say thePaintbox.Refresh.

--
David Ullrich

sig.txt not found

Other Threads