How to set TImage size and clear TImage picture?

Posted on 2005-03-03
Medium Priority
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".
Question by:mikezang
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 14

Accepted Solution

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

2.) grid.clear
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;

Assisted Solution

zion29 earned 100 total points
ID: 13456815
If it is a standard canvas, a "grid.canvas.repaint" should be enough. :)
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

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

Expert Comment

by:Pierre Cornelius
ID: 13456946
LVL 14

Expert Comment

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

Expert Comment

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


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

743 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