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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with bitmaps

Status
Not open for further replies.

abcfantasy

Programmer
Jun 3, 2006
110
DK
Hello, I'm having a problem with bitmaps when passed as parameters. I've got the following procedure in a unit:

Code:
procedure TMap.CopyArea( pImage: TBitmap; X, Y: integer );
var SourceRect, DestRect: TRect;
    Map_Image: TBitmap;
begin
  {some code}
  pImage.Canvas.CopyRect( DestRect, Map_Image.Canvas, SourceRect );
end;

Then in my main program, I've got a TImage component (named image_Map) and I've got the following code:

Code:
procedure Tform_Main.FormCreate(Sender: TObject);
begin
  Map := TMap.Create;
  Map.CopyArea( image_Map.Picture.Bitmap, 50, 50 );
end;

However the result is that image_Map remains blank and nothing is displayed. Am I missing something?

Thank you in advance
Andrew

ABC -
 
The TImage have an image loaded?

Only creating the TImage will not set the internal bitmap sizes (and perhaps neither the bitmap format nor other things); may be you are calling the copy function with a bitmap which is not functional.

buho (A).
 
No the TImage has no image loaded.

Now I loaded a blank image into the TImage at design time, and the copying worked fine.

But is this (ie. loading a "dummy" image) a good and clean way to get it working or is there a better way?

ABC -
 
Without loading the image:

a) Manually initialize the TImage.Picture.Bitmap sizes and try.

If it does not work then:

b) Manually initialize the the TBitmap.PixelFormat too and try again.

If it still does not work then:

c) Check the TBitmap properties and try to guess what other thing can need initialization.

buho (A).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top