--
Greatings,
Ronald Hoek
Application developper
ComponentAgro B.V.
Barendrecht
Phone. +31-180-621306
Fax. +31-180-611797
> In the about dialog box of out application we would like to show a moving
> image. I've tried this, but it just flashes when I move the image.
As a quick hack, try setting the value of the image's parent control's
DoubleBuffered (run-time) property to True. This works for TForm
descendants, for example. It removes the flashing, but not the jerking,
since this would require synchronization to the monitor's refresh rate.
No idea on how to accomplish that outside of DirectX :(
--
Antti Piirainen
Software Engineer, Camline Corporation (http://www.camline.fi/)
Mobile: +358-40-5222772 | Fax: +358-5-6214242
Create a background bitmap the size of the control you'll be drawing on.
Copy the background of the control you will be drawing on into this
background bitmap (draw the control onto the background bitmap canvas).
Create an intermediate bitmap and set its width and height to the maximum
distance the image will move between redraws, plus the size of the image
itself.
Each time you move the image and need to repaint the image on the
destination (control or form) canvas, follow these steps:
1. Calculate the new location rect of the image
2. Calculate the union of the old image rect and the new image rect. This
is the update rect.
3. Copy the update rect area from the background bitmap to the intermediate
bitmap at coordinate 0,0. This will erase the old image from the
destination in the last step.
4. Draw the image on the intermediate bitmap. You'll need to subtract the
update rect's origin from the new image rect origin to place the image in
the right location in the intermediate bitmap. (If the new image rect is in
the top left corner of the update rect, draw the image at 0,0 in the
intermediate bitmap. etc)
5. Finally, draw the intermediate bitmap onto the destination canvas at the
update rect location. This will erase the old image and draw the new image
in one blit operation, eliminating flicker.
All bitmaps should be set to match the screen pixel format.
You will have to decide what time interval is appropriate to redraw the
image. You should probably use a timer message, as a continuous loop would
run too fast and take up too much CPU time. Since most monitors refresh the
screen between 60 and 90 times per second, there's not much need to run the
refresh timer much faster than that.
-Danny
There's a nice example of using clipping regions for fast drawing an Earl
Glynn's site. Go to
http://www.efg2.com/Lab/Library/Delphi/Graphics/Algorithms.htm and search
for Prilutsky.
Gordon
There were some good suggestions already:
1) Set "doublebuffered" to true
2) Do not use a fully windowed control, but rather a drawing element
And here's another two:
3) You can also draw your image simply to the bitmap of the picture, and
make sure the picture's bitmap itself does not change size
4) Catch the WM_ERASEBKGND message (search on Google.. many posts here
before)
Kind regards (also from Holland),
Nils Haeck
www.simdesign.nl
"R. Hoek" <*ho...@componentagro.nl> wrote in message
news:3f52ff70$1...@newsgroups.borland.com...