Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to clear all canvas 1

Status
Not open for further replies.

ozgurtekin

Programmer
Apr 22, 2003
17
TR
How can I clear a specific canvas object like a bitmap?
Also how can I clear lines done with line to method.
Also how can I move a bitmap thats done with canvas?

 
What exactly do you want to do when you say "clear a specific canvas object"?

The easiest way to clear lines done with LineTo is to set the canvas pen to the background colour you want and then call an identical LineTo procedure again.

This will not work if your line has been drawn over a multi colour background (such as a photograph). In this case a simple solution might be to save the canvas somewhere and then restore it when necessary.

What exactly do you mean by "move a bitmap thats done with canvas"?





 
I want to have a bitmap moving around the screen.
Like Left or Top, does it have any property controlling the position.

Can I place a bitmap in the design phase or is it only created in command lines?

Is it possible to delete a bitmap or line or any canvas from the application?
 
You need a TImage component (from the Additional palette) on your form. TImage has Left and Top properties that can be changed at Run time to give the effect of moving around the canvas.

The TImage component has a Picture property. You can load various graphic types (such as a bit map, Jpeg etc) into the Picture.

You could create (and destroy) your TImage object at run time if you want. You could hide the TImage object by changing the value of its Visible property.

My previous reply suggested a couple of ways to delete lines from the canvas. Do these meet your requirements?

Andrew
 
Hi,
just to be clear,

when you use a TImage and set Top and Left property you don't write directly on the canvas, so you don't have to clear old shadows, but it will work only inside your delphi application. Ask google about Sprites.

If you want to display a moving picture on the *screen* for a screen-saver (for example), consider the possibility of draw a ScreenShot on a maximized form's canvas and place over it the moving TPicture.
Otherwise, it's a little more difficult, because you should manage "DeviceContext", "Regions" and canvases outside your app, and this may require some API knowledge.

You can use the "canvas approach" with TForm.Canvas to make some tests and then write on the screen or other parts (Start-menu, Window Borders, Desktop and so on), but outside Delphi's door you'll find a difficult world.

Take in mind that when you are writing on a canvas, you are not building "consistent" objects (with top&left props.), instead your are just changing the color of some "unrelated" pixels, so you should take care on what you change (and on what was the color before).

Ciao,
Geppo Darkson.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top