?
Solved

How to set TImage size and clear TImage picture?

Posted on 2005-03-03
9
Medium Priority
?
1,402 Views
Last Modified: 2008-01-09
I have two TImages, "source" is for picture itself, "grid" is for draw grid with transparent=true, so that the "source" can be viewed. My question as below:
1. When  picture is loaded into "source" ,
source.Picture.Graphic := Bitmap;

how do I set "grid" to the same size with "source? next code seems doesn't work.
grid.Width := Bitmap.Width;
grid.Height := Bitmap.Height;

2. How can I clear all grid what I drawed in "grid".
0
Comment
Question by:mikezang
7 Comments
 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 100 total points
ID: 13456659
1.)
grid.Width:= source.width
grid.Height:= source.height

2.) grid.clear
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 13456675
Sorry, the second suggestion is wrong to clear a image. Try this rather:

  grid.Canvas.Brush.Color:= clBtnFace; //or whatever color you want as the background
  grid.Canvas.Pen.Color:= clBtnFace;
  grid.Canvas.Rectangle(Image1.ClientRect);
0
 
LVL 1

Assisted Solution

by:zion29
zion29 earned 100 total points
ID: 13456815
If it is a standard canvas, a "grid.canvas.repaint" should be enough. :)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:mikezang
ID: 13456906
if a file is loaded into source, then I drawed something on it, then load file again, is my drawing also cleared?
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 13456946
Yes
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 13456951
Unless you save the file with your changes before loading it again.
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 13459362
to clear image box, try

Image.Picture.Assign(nil);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question