Solved

Copying bmps to to TImage

Posted on 2000-05-12
5
305 Views
Last Modified: 2010-04-04
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
Comment
Question by:ChrisBerry
5 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 50 total points
Comment Utility
Have you set the dimensions of the destination bitmap before you did the copy?

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

The Neil =:)
0
 
LVL 4

Expert Comment

by:BoRiS
Comment Utility
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
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Hi BoRiS, nice to see you...   :-)
0
 
LVL 4

Expert Comment

by:BoRiS
Comment Utility
Hi Madshi

Good to be back ;-)

Later
BoRiS
0
 

Author Comment

by:ChrisBerry
Comment Utility
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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now