This procedure loads a bitmap image from a file and displays it in its entirety to a VCL form. The procedure uses the Height and Width properties of the Bitmap object to display a full view of the image.
New
Other
Delphi Projects or C++Builder Projects and double-click the VCL Forms Application icon. The VCL Forms Designer is displayed.
Bitmap := TBitmap.Create;
try
Bitmap.LoadFromFile('MyFile.bmp');
Form1.Canvas.Brush.Bitmap := Bitmap;
Form1.Canvas.FillRect(Rect(0,0,Bitmap.Width,Bitmap.Height));
finally
Form1.Canvas.Brush.Bitmap := nil;
Bitmap.Free;
end;
Graphics::TBitmap Bitmap = new Graphics::TBitmap(); try { Bitmap->LoadFromFile( “..\\MyFile.bmp” ); Form1–>Canvas->Brush->Bitmap = Bitmap; Form1–>Canvas->FillRect( Rect( 0, 0, Bitmap->Width, Bitmap->Height ) ); } __finally { Form1–>Canvas->Brush->Bitmap = NULL; Bitmap->Free(); }
Bitmap : TBitmap;s
Run. |
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
|
What do you think about this topic? Send feedback!
|