unit Unit1;
{$mode objfpc}{$H+}
interface
uses
FileUtil, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls,
ExtCtrls, Buttons, ExtDlgs, GR32_Image;
type
{ TForm1 }
TForm1 = class(TForm)
ImageList1: TImageList;
ImgView32_1: TImgView32;
OpenPictureDialog1: TOpenPictureDialog;
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
private
FImages: TStringList;
FCurrentIndex: Integer;
procedure LoadImage(const APrev: Boolean);
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
FImages := TStringList.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FImages.Free;
end;
procedure TForm1.ToolButton1Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
begin
FImages.Clear;
FindAllFiles(FImages, ExtractFileDir(OpenPictureDialog1.FileName) + PathDelim, '*.jpg; *.jpeg', True);
FCurrentIndex := FImages.IndexOf(OpenPictureDialog1.FileName);
LoadImage(False);
end;
end;
procedure TForm1.ToolButton3Click(Sender: TObject);
begin
LoadImage(True);
end;
procedure TForm1.ToolButton4Click(Sender: TObject);
begin
LoadImage(False);
end;
procedure TForm1.LoadImage(const APrev: Boolean);
var
ImageIndex: Integer;
begin
ImageIndex := FCurrentIndex;
if APrev then
begin
if FCurrentIndex > 0 then
Dec(FCurrentIndex)
end else
begin
if FCurrentIndex < FImages.Count -1 then
Inc(FCurrentIndex);
end;
ImgView32_1.Bitmap.LoadFromFile(FImages[ImageIndex]);
Form1.Caption := ExtractFileName(FImages[ImageIndex]);
StatusBar1.Panels[0].Text := IntToStr(ImgView32_1.Bitmap.Width) +'x'+ IntToStr(ImgView32_1.Bitmap.Height);
StatusBar1.Panels[1].Text := IntToStr(FCurrentIndex) +' / '+ IntToStr(FImages.Count);
end;
end.