205 lines
5.6 KiB
Plaintext
205 lines
5.6 KiB
Plaintext
(*
|
|
Demo application to show TImageEnMView.InsertTransitionFrames and TImageEnProc.CreateTransitionBitmap
|
|
|
|
Copyright Xequte Software 2011
|
|
|
|
www.ImageEn.com
|
|
*)
|
|
|
|
|
|
unit uMain;
|
|
// NPC: 25/10/11
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, iexTransitions,
|
|
ieview, iemview, imageenview, imageenproc, StdCtrls, Spin, Hyieutils, iexBitmaps,
|
|
hyiedefs, iesettings, iexLayers, iexRulers;
|
|
|
|
type
|
|
TForm1 = class(TForm)
|
|
ImageEnMView1: TImageEnMView;
|
|
btnCreateTransitions: TButton;
|
|
ImageEnProc: TImageEnProc;
|
|
btnCreatePanZoom: TButton;
|
|
btnInsertTransitions: TButton;
|
|
spnInsertIdx: TSpinEdit;
|
|
btnReset: TButton;
|
|
btnInsertPanZoom: TButton;
|
|
Label1: TLabel;
|
|
Label2: TLabel;
|
|
spnFrameCount: TSpinEdit;
|
|
Label3: TLabel;
|
|
edtSaveFolder: TEdit;
|
|
Label4: TLabel;
|
|
cmbTransition: TComboBox;
|
|
lblTransition: TLabel;
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure btnCreateTransitionsClick(Sender: TObject);
|
|
procedure btnCreatePanZoomClick(Sender: TObject);
|
|
procedure FormShow(Sender: TObject);
|
|
procedure btnInsertTransitionsClick(Sender: TObject);
|
|
procedure btnResetClick(Sender: TObject);
|
|
procedure btnInsertPanZoomClick(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
procedure ResetImageEnMView;
|
|
function DemoImage1Path : string;
|
|
function DemoImage2Path : string;
|
|
function GetSelectedTransitionEffect: TIETransitionType;
|
|
procedure SetSelectedTransitionEffect(const Value: TIETransitionType);
|
|
public
|
|
property SelectedTransitionEffect: TIETransitionType read GetSelectedTransitionEffect write SetSelectedTransitionEffect;
|
|
end;
|
|
|
|
var
|
|
Form1: TForm1;
|
|
|
|
implementation
|
|
|
|
{$R *.DFM}
|
|
{$R WindowsTheme.res}
|
|
|
|
const
|
|
Default_Transition_Effect = iettRandomPoints;
|
|
|
|
|
|
|
|
procedure TForm1.FormCreate(Sender: TObject);
|
|
var
|
|
I: Integer;
|
|
begin
|
|
cmbTransition.Clear;
|
|
for I := Low(IETransitionList) to High(IETransitionList) do
|
|
cmbTransition.Items.Add(IETransitionList[I].name);
|
|
SelectedTransitionEffect := Default_Transition_Effect;
|
|
end;
|
|
|
|
procedure TForm1.btnCreateTransitionsClick(Sender: TObject);
|
|
var
|
|
OldBitmap, NewBitmap : TIEBitmap;
|
|
TransBitmap : TBitmap;
|
|
I : Integer;
|
|
TransLevel : Single;
|
|
begin
|
|
OldBitmap := TIEBitmap.Create;
|
|
NewBitmap := TIEBitmap.Create;
|
|
TransBitmap := TBitmap.Create;
|
|
try
|
|
OldBitmap.Read(DemoImage1Path);
|
|
NewBitmap.Read(DemoImage2Path);
|
|
|
|
// Call PrepareTransitionBitmaps once
|
|
ImageEnProc.PrepareTransitionBitmaps(OldBitmap.VclBitmap, NewBitmap.VclBitmap, SelectedTransitionEffect);
|
|
|
|
for i := 1 to 9 do
|
|
begin
|
|
// We want levels from 10% to 90%
|
|
TransLevel := i * 10;
|
|
|
|
// Call CreateTransitionBitmap for each required frame
|
|
ImageEnProc.CreateTransitionBitmap(TransLevel, TransBitmap);
|
|
TransBitmap.SaveToFile(IncludeTrailingBackslash(edtSaveFolder.Text) + 'TransImage' + IntToStr(I) + '.bmp');
|
|
end;
|
|
|
|
finally
|
|
OldBitmap.Free;
|
|
NewBitmap.Free;
|
|
TransBitmap.Free;
|
|
end;
|
|
end;
|
|
|
|
procedure TForm1.btnCreatePanZoomClick(Sender: TObject);
|
|
var
|
|
MyBitmap : TIEBitmap;
|
|
PanZoomBitmap : TBitmap;
|
|
I : Integer;
|
|
TransLevel : Single;
|
|
StartingRect, EndingRect : TRect;
|
|
begin
|
|
MyBitmap := TIEBitmap.Create;
|
|
PanZoomBitmap := TBitmap.Create;
|
|
try
|
|
MyBitmap.Read(DemoImage2Path);
|
|
|
|
StartingRect := Rect(0, 0, 200, 200);
|
|
EndingRect := Rect(170, 420, 430, 520);
|
|
|
|
// Call PrepareTransitionBitmaps once
|
|
ImageEnProc.PrepareTransitionBitmapsEx(MyBitmap.VclBitmap, nil, iettPanZoom, StartingRect, EndingRect, True, 200, 200);
|
|
|
|
for i := 0 to 10 do
|
|
begin
|
|
// We want levels from 0% to 100%
|
|
TransLevel := i * 10;
|
|
|
|
// Call CreateTransitionBitmap for each required frame
|
|
ImageEnProc.CreateTransitionBitmap(TransLevel, PanZoomBitmap);
|
|
PanZoomBitmap.SaveToFile(IncludeTrailingBackslash(edtSaveFolder.Text) + 'PanZoomImage' + IntToStr(I) + '.bmp');
|
|
end;
|
|
|
|
finally
|
|
MyBitmap.Free;
|
|
PanZoomBitmap.Free;
|
|
end;
|
|
end;
|
|
|
|
procedure TForm1.FormShow(Sender: TObject);
|
|
begin
|
|
edtSaveFolder.Text := IncludeTrailingBackslash(ExtractFilePath(Application.ExeName));
|
|
ResetImageEnMView;
|
|
end;
|
|
|
|
function TForm1.GetSelectedTransitionEffect: TIETransitionType;
|
|
begin
|
|
Result := TIETransitionType(cmbTransition.ItemIndex + 1)
|
|
end;
|
|
|
|
procedure TForm1.btnInsertTransitionsClick(Sender: TObject);
|
|
var
|
|
ARect: Trect;
|
|
begin
|
|
ARect := Rect(0, 0, 0, 0);
|
|
ImageEnMView1.InsertTransitionFramesEx(spnInsertIdx.Value, spnFrameCount.Value, SelectedTransitionEffect, ARect , ARect, true, -1, -1, False, clBlack);
|
|
end;
|
|
|
|
procedure TForm1.btnResetClick(Sender: TObject);
|
|
begin
|
|
ResetImageEnMView;
|
|
end;
|
|
|
|
procedure TForm1.btnInsertPanZoomClick(Sender: TObject);
|
|
var
|
|
StartingRect, EndingRect : TRect;
|
|
begin
|
|
StartingRect := Rect(0, 0, 200, 200);
|
|
EndingRect := Rect(300, 300, 500, 500);
|
|
ImageEnMView1.InsertTransitionFramesEx(spnInsertIdx.Value, spnFrameCount.Value, iettPanZoom, StartingRect, EndingRect, True, 200, 200);
|
|
end;
|
|
|
|
procedure TForm1.ResetImageEnMView;
|
|
begin
|
|
ImageEnMView1.Clear;
|
|
ImageEnMView1.AppendImage(DemoImage1Path);
|
|
ImageEnMView1.AppendImage(DemoImage2Path);
|
|
end;
|
|
|
|
procedure TForm1.SetSelectedTransitionEffect(const Value: TIETransitionType);
|
|
begin
|
|
cmbTransition.ItemIndex := ord(Default_Transition_Effect) -1;
|
|
end;
|
|
|
|
function TForm1.DemoImage1Path: string;
|
|
begin
|
|
Result := IncludeTrailingBackslash(ExtractFilePath(Application.ExeName)) + 'Butterfly.jpg';
|
|
end;
|
|
|
|
function TForm1.DemoImage2Path: string;
|
|
begin
|
|
Result := IncludeTrailingBackslash(ExtractFilePath(Application.ExeName)) + 'StickSea.jpg';
|
|
end;
|
|
|
|
end.
|
|
|