Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

Copying bmps to to TImage

Hi,

I think one of my marbles is a bit loose!:-)

I am trying to copy a section of a bmp from a TImage to another TImage using CopyRect. Why can I only see the copied image if I have an existing bmp in the destination TImage? I addition the copied bmp will only overlay the parts of the image currently covered by the existing bmp.

How can I just copy the section of the source bmp in the TImage to the destination TImage with no pre-existing bmp?

Regards

Chris
0
ChrisBerry
Asked:
ChrisBerry
1 Solution
 
TheNeilCommented:
Have you set the dimensions of the destination bitmap before you did the copy?

Image1.Picture.Bitmap.Width := ...

The Neil =:)
0
 
BoRiSCommented:
ChrisBerry

Does your code look anything like this, cause I just wrote this and it worked fine

var
  Bitmap: TBitmap;
  FirstRect, OtherRect: TRect;
begin
  FirstRect := Rect(0, 0, 10, 10);
  OtherRect := Rect(10, 10, 30, 30);
  Bitmap := TBitmap.Create;
  Bitmap.LoadFromFile('c:\windows\bubbles.bmp');
Form1.Canvas.CopyRect(OtherRect, Bitmap.Canvas, FirstRect);
  Bitmap.Free;
end;

Later
BoRiS
0
 
MadshiCommented:
Hi BoRiS, nice to see you...   :-)
0
 
BoRiSCommented:
Hi Madshi

Good to be back ;-)

Later
BoRiS
0
 
ChrisBerryAuthor Commented:
Hi all,

Thanks for your replies.

Neil was right, I was setting the TImage width/height not the bitmap.

BoRiS, yes I did get that to work. My problem was with TImage not form canvas.

Thanks

Chris
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now