Grant Fullen
asked on
Create tImages Dynamicly at runtime.
I need to point (browse) for a folder of images and for example there are 16 jpegs in the folder then i need to populate my Page Control "TabSheet10" with a timage for each jpg (ie. 16 Timages) . I just need a thumbnail view and if i double click on an image it will open the actual picture.jpg with the defalt windows viewer.
This needs to be dynamics so if the are 5 jpeg then 5 Timages will be created on the tabsheet 10.
This information needs to be saved and loaded each time the application is run.
I have no ideal where to start on this and do not want to waste time going in the wronge direction.
I need example code for this.
This needs to be dynamics so if the are 5 jpeg then 5 Timages will be created on the tabsheet 10.
This information needs to be saved and loaded each time the application is run.
I have no ideal where to start on this and do not want to waste time going in the wronge direction.
I need example code for this.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Make sure you have ExtCtrls in your uses.
ASKER
I tried your code and it only loads 1 bmp. I need to load all .jpg in a folder into seperate timages.
ASKER
I was looking at TJvThumbnail component it supports .jpg this would be better to use than a timage .
you have to loop the code ThievingSix provided for every image in your folder
And if you wish to use a jpg look here: http://www.thecodecave.com/treating-a-timages-loaded-jpeg-as-a-bitmap-in-delphi/
And as xr1140 says you will need to call CreateTImage for every image in the folder. If you need an example of this look here: http://delphi.about.com/od/vclusing/a/findfile.htm
And as xr1140 says you will need to call CreateTImage for every image in the folder. If you need an example of this look here: http://delphi.about.com/od/vclusing/a/findfile.htm
You might wanna use an array of TImages for this purpose
for instance:
for instance:
const maxpic = 1024;
var
form1: Tform1;
myArr: Array[0..maxpic] of TImage;
Procedure loadimages(Pictures:Tstringlist)
var
I:Integer;
Begin
for i = 0 to SizeOf(myArr) do myArr[I].free;// first free any previous instances
ZeroMemory(@MyArr,SizeOf(MyArr)); // Zero the array;
// loop trough the Pictures Tstringlist which will contain filepath of picture
for i = 0 to pictures.count-1 do
begin
//now use the function provided by thievingsix
MyArr[I] := CreateTImage('Image1',Form1,0,0,100,100); // set the X:Y values after desired position
MyArr[I].Picture.LoadFromFile(Pictures.strings[0]);
end;
end;
end;
Hope this was helpfull.
ASKER
Have not got to try this stuff yet but will soon.