Board index » delphi » Problem panning TCanvas w/CopyRect

Problem panning TCanvas w/CopyRect

I need a high-speed method for panning TCanvas for an on-screen
strip-chart recorder/grapher (like the paper that comes out of an EKG
machine). The only way that I've been able to concoct one that works
correctly is to do an ultra-slow nested loop like this :

For x := 0 to Width-DeltaX-1 do
  For y := 0 to Height-1 do
    Canvas.Pixels[x,y] := Canvas.Pixels[x+Delta,y];

  This is too slow. So, I tried using CopyRect and was pleased to see
how fast it worked. But, CopyRect has this annoying habit of grabbing
the contents of overlapping windows (see example linked below). Is there
a way to create an invisible canvas, paint on it, and copy it onto a
visible canvas ? This would do it, I think.

Example :
http://personalweb.sierra.net/~bktahoe/PanCanvas/PanCanvas.html **

** Includes some extraneous objects that you may find useful as an
incentive to get your attention. "Oooh, rotating polygons. Pinch me."

Thanks in advance
BK
----------------------------------------------------------
BKTahoe a.k.a. Brad Kilmer
mailto:BKTa...@sierra.net
http://personalweb.sierra.net/~bktahoe/BKTahoe.html
----------------------------------------------------------
Accute thinker from Nevada's obtuse vertex.
----------------------------------------------------------

 

Re:Problem panning TCanvas w/CopyRect


Quote
Brad Kilmer wrote:

> I need a high-speed method for panning TCanvas for an on-screen
> strip-chart recorder/grapher (like the paper that comes out of an EKG
> machine). The only way that I've been able to concoct one that works
> correctly is to do an ultra-slow nested loop like this :

> For x := 0 to Width-DeltaX-1 do
>   For y := 0 to Height-1 do
>     Canvas.Pixels[x,y] := Canvas.Pixels[x+Delta,y];

>   This is too slow. So, I tried using CopyRect and was pleased to see
> how fast it worked. But, CopyRect has this annoying habit of grabbing
> the contents of overlapping windows (see example linked below). Is there
> a way to create an invisible canvas, paint on it, and copy it onto a
> visible canvas ? This would do it, I think.

> Example :
> http://personalweb.sierra.net/~bktahoe/PanCanvas/PanCanvas.html **

> ** Includes some extraneous objects that you may find useful as an
> incentive to get your attention. "Oooh, rotating polygons. Pinch me."

> Thanks in advance
> BK
> ----------------------------------------------------------
> BKTahoe a.k.a. Brad Kilmer
> mailto:BKTa...@sierra.net
> http://personalweb.sierra.net/~bktahoe/BKTahoe.html
> ----------------------------------------------------------
> Accute thinker from Nevada's obtuse vertex.
> ----------------------------------------------------------

Yes, manually create a TBitmap object (whith the same size as
the target canvas). Draw on its canvas offscreen.
Then copy the entire contents to the visible canvas in the onpaint
method.
Use invalidate-rect with no background/erasing to selectively
update portions of your visible canvas.
No flickering, fast updating.

Henk Hagedoorn

freew...@bigfoot.com
h...@usa.net

           +++++++++++++++++++++++++++++++++++++++++++++++
           +  Check out my Windows 95 freeware page at:  +
           +  http://hjh.simplenet.com/freew1.htm        +
           +++++++++++++++++++++++++++++++++++++++++++++++

Re:Problem panning TCanvas w/CopyRect


Reposting article removed by rogue canceller.

Quote
Brad Kilmer wrote:

> I need a high-speed method for panning TCanvas for an on-screen
> strip-chart recorder/grapher (like the paper that comes out of an EKG
> machine). The only way that I've been able to concoct one that works
> correctly is to do an ultra-slow nested loop like this :

> For x := 0 to Width-DeltaX-1 do
>   For y := 0 to Height-1 do
>     Canvas.Pixels[x,y] := Canvas.Pixels[x+Delta,y];

>   This is too slow. So, I tried using CopyRect and was pleased to see
> how fast it worked. But, CopyRect has this annoying habit of grabbing
> the contents of overlapping windows (see example linked below). Is there
> a way to create an invisible canvas, paint on it, and copy it onto a
> visible canvas ? This would do it, I think.

> Example :
> http://personalweb.sierra.net/~bktahoe/PanCanvas/PanCanvas.html **

> ** Includes some extraneous objects that you may find useful as an
> incentive to get your attention. "Oooh, rotating polygons. Pinch me."

> Thanks in advance
> BK
> ----------------------------------------------------------
> BKTahoe a.k.a. Brad Kilmer
> mailto:BKTa...@sierra.net
> http://personalweb.sierra.net/~bktahoe/BKTahoe.html
> ----------------------------------------------------------
> Accute thinker from Nevada's obtuse vertex.
> ----------------------------------------------------------

Yes, manually create a TBitmap object (whith the same size as
the target canvas). Draw on its canvas offscreen.
Then copy the entire contents to the visible canvas in the onpaint
method.
Use invalidate-rect with no background/erasing to selectively
update portions of your visible canvas.
No flickering, fast updating.

Henk Hagedoorn

freew...@bigfoot.com
h...@usa.net

           +++++++++++++++++++++++++++++++++++++++++++++++
           +  Check out my Windows 95 freeware page at:  +
           +  http://hjh.simplenet.com/freew1.htm        +
           +++++++++++++++++++++++++++++++++++++++++++++++

Other Threads