View Single Post
Old 12-17-2009, 04:59 PM
GordC GordC is offline
Junior Member
Join Date: Jul 2009
Posts: 3

Just to expand on creating images from bitmaps and jpgs, the following code may be of interest to members.
// Under global var declarations add the following
var Form1: Tform1; //already present
myBmp: TBitmap;
myImg: TImage; // add ExtCtrls to uses section
jImg: TJPEGImage; // add JPEG to uses section
// to create and display a bitmap file
myBmp:= TBitmap.Create;
myImg:= Timage.Create(form1); //note parameter 'form1'
myBmp.LoadFromFile('path and name of file') //must be a bitmap file
myImg.picture.graphic:= myBmp; //displays picture;
// to create and display a jpg file
jImg:= TJpegImage.Create;
myBmp:= TBitmap.Create; //
jImg.LoadFromFile('path and name of file'); //must be a jpg file
myBmp.Assign(jImg); //copy internally
myImg.picture.Bitmap:=myBmp; //display file;
You can put this code into a FormCreate or a ButtonClick event handler.
Also you might want to use the OpenDialog to select the file(s).
Note the subtle differences between 'Creates'.
Gord C
Reply With Quote