procedure TForm1.VerticalGrid1Click(Sender: TObject);
{ Show the images in a vertical grid similar to Adobe Reader.
{ This would have to be run in a secondary thread to maintain an active GUI.
{ This is reasonably fast for up to about 25-50 images }
var
i: integer;
y: integer;
iWidth: integer;
iHeight: integer;
iBitmap: TBitmap;
iSpaceBetweenImages: integer;
begin
Screen.Cursor := crHourGlass;
try
{ Set the dimensions of the image to draw to- all images must have the same dimensions }
iSpaceBetweenImages := 25; { vertical space between images in pixels }
iWidth := ImageEnMView1.ImageOriginalWidth[0];
iHeight := (ImageEnMView1.ImageOriginalHeight[0] + iSpaceBetweenImages) *
ImageEnMView1.ImageCount;
try
{ Try to create a bitmap large enough to hold all the images }
{ Image the bitmap is too large an exception will ocur }
ImageEnView2.Proc.ImageResize(iWidth, iHeight);
i := 0;
y := 0;
while y < iHeight do
begin
iBitmap := TBitmap.Create;
{ Get the image from ImageEnMview }
iBitmap.Assign(ImageEnMView1.GetBitmap(i));
{ Draw the image to ImageEnView2.Bitmap.Canvas }
ImageEnView2.Bitmap.Canvas.Draw(0, y, iBitmap);
Application.ProcessMessages;
ImageEnView2.Update;
{ Set the y position for next image }
y := y + iBitmap.Height + iSpaceBetweenImages;
{ Free the bitmap }
ImageEnMView1.ReleaseBitmap(i);
{ Image number }
inc(i);
end;
except
on E: Exception do
begin
ShowMessage('Exception class name = ' + E.ClassName);
ShowMessage('Exception message = ' + E.Message);
end;
end;
finally
Screen.Cursor := crDefault;
end;
end;
procedure TForm1.ThumbnailVerticalGrid1Click(Sender: TObject);
{ Show thumbnails of the images in a vertical grid.
This requires iexHelperFunctions.pas that is in the latest version of imageen }
var
i: integer;
y: integer;
iWidth: integer;
iHeight: integer;
iThumbnailHeight: integer;
iThumbnailWidth: integer;
iBitmap: TBitmap;
iSpaceBetweenImages: integer;
begin
{ Use this if you have a large number of images or images are of large size.
This draws a 1/3 size thumbnail of each image. Unfortunately if you have a large (> 50)
number of images this will take several seconds (30-40 sceconds) to complete. This
would have to be run in a secondary thread to maintain an active GUI. }
Screen.Cursor := crHourGlass;
try
ImageEnView2.Clear;
{ Set the dimensions of the image to draw to- all images must have the same dimensions }
iSpaceBetweenImages := 25; { vertical space between images in pixels }
iWidth := ImageEnMView1.ImageOriginalWidth[0] div 3;
iHeight := (ImageEnMView1.ImageOriginalHeight[0] div 3 + iSpaceBetweenImages) *
ImageEnMView1.ImageCount;
iThumbnailWidth := ImageEnMView1.ImageOriginalWidth[0] div 3;
iThumbnailHeight := ImageEnMView1.ImageOriginalHeight[0] div 3;
try
{ Try to create a bitmap large enough to hold all the images }
{ Image the bitmap is too large an exception will occur }
ImageEnView2.Proc.ImageResize(iWidth, iHeight);
i := 0;
y := 0;
while y < iHeight do
begin
iBitmap := TBitmap.Create;
{ Get the image from ImageEnMview }
iBitmap.Assign(ImageEnMView1.GetBitmap(i));
{ Convert the bitmap to a thumbnail to reduce memory requirements }
iBitmap.IEConvertToThumbnail(iThumbnailWidth, iThumbnailHeight, True, rfLanczos3, True, clWhite, True, 4, 4, clBlack);
{ OR resample the image to 1/3 size
iBitmap.IEResample(iThumbnailWidth, -1); }
{ Draw the image to ImageEnView2.Bitmap.Canvas }
ImageEnView2.Bitmap.Canvas.Draw(0, y, iBitmap);
ImageEnView2.Update;
{ This is necessary to update each image when it is drawn }
Application.ProcessMessages;
{ Set the y position for next image }
y := y + iBitmap.Height + iSpaceBetweenImages;
{ Free the bitmap }
ImageEnMView1.ReleaseBitmap(i);
{ Image number }
inc(i);
end;
except
on E: Exception do
begin
ShowMessage('Exception class name = ' + E.ClassName);
ShowMessage('Exception message = ' + E.Message);
end;
end;
finally
Screen.Cursor := crDefault;
end;
end;
William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html