The images iam loading are slightly different sizes. how can i get the smallest size and re-size them all to that size?
The code below is the loading of the images -> converting to bmp -> adding to imagelist
after about 3 images it gives error invalid image size. due to image size too big for the size i gave imagelist at start.
procedure TForm1.LoadImages(const Dir: string);
var
z,i: Integer;
CurFileName: string;
JpgIn: TJPEGImage;
BmpOut: TBitmap;
begin
i := 0;
z := 1;
while True do
begin
CurFileName := Format('%s%d.jpg',
[IncludeTrailingPathDelimiter(Dir), i]);
if not FileExists(CurFileName) then
Break;
JpgIn := TJPEGImage.Create;
try
JpgIn.LoadFromFile(CurFileName);
if z = 1 then
begin
ImageList1.SetSize(jpgin.width, jpgin.Height);
z := 0;
end;
BmpOut := TBitmap.Create;
try
BmpOut.Assign(JpgIn);
ImageList1.Add(BmpOut, nil);
finally
BmpOut.Free;
end;
finally
JpgIn.Free;
end;
Inc(i);
end;
if ImageList1.Count > 0 then
begin
BmpOut := TBitmap.Create;
try
ImageList1.GetBitmap(1, BmpOut);
zimage1.Bitmap.Assign(bmpout);
zimage1.Repaint;
finally
BmpOut.Free;
end;
end;
end;