Is it possible to build a demo for my question?
Left list is backgrounds, right list is layers.
I think this will help more people understand.
Thank you very much.
unit unMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, JvToolEdit, Vcl.StdCtrls, Vcl.Mask,
JvExMask, Vcl.ExtCtrls, hyieutils, iexBitmaps, hyiedefs, iesettings,
iexLayers, iexRulers, ieview, iemview, imageenview;
type
TfrmMain = class(TForm)
Panel1: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Panel5: TPanel;
Panel6: TPanel;
ImageEnMView2: TImageEnMView;
ImageEnMView1: TImageEnMView;
ImageEnView1: TImageEnView;
btnAddBackground: TButton;
btnAddLayer: TButton;
Button3: TButton;
Button4: TButton;
OpenDialogBackground: TOpenDialog;
OpenDialogLayer: TOpenDialog;
btnCreateCombinations: TButton;
procedure ImageEnMView1ImageSelect(Sender: TObject; idx: Integer);
procedure ImageEnMView2ImageSelect(Sender: TObject; idx: Integer);
procedure btnAddBackgroundClick(Sender: TObject);
procedure btnAddLayerClick(Sender: TObject);
procedure btnCreateCombinationsClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
cntBackground, cntLayers, cntCombinations: integer;
imgBackgroundLeft, imgBackgroundTop, imgBackgroundWidth, imgBackgroundHeight: integer;
imgLayerLeft, imgLayerTop, imgLayerWidth, imgLayerHeight: integer;
implementation
{$R *.dfm}
procedure TfrmMain.btnAddBackgroundClick(Sender: TObject);
begin
ImageEnView1.IO.Params.PSD_LoadLayers := true;
if OpenDialogBackground.Execute then
begin
ImageEnMView1.FillFromList(OpenDialogBackground.Files);
ImageEnView1.CurrentLayer.Width := 1000;
ImageEnView1.CurrentLayer.Height := 1000;
end;
end;
procedure TfrmMain.btnAddLayerClick(Sender: TObject);
begin
ImageEnView1.IO.Params.PSD_LoadLayers := true;
if OpenDialogLayer.Execute then
begin
ImageEnMView2.FillFromList(OpenDialogLayer.Files);
ImageEnView1.CurrentLayer.Width := 1000;
ImageEnView1.CurrentLayer.Height := 1000;
end;
end;
procedure TfrmMain.btnCreateCombinationsClick(Sender: TObject);
var
background, layer: integer;
ExtName: string;
begin
cntBackground := ImageEnMView1.ImageCount;
cntLayers := ImageEnMView2.ImageCount;
cntCombinations := cntBackground * cntLayers;
ExtName := '.jpg';
(*
imgBackgroundLeft, imgBackgroundTop, imgBackgroundWidth, imgBackgroundHeight: integer;
imgLayerLeft, imgLayerTop, imgLayerWidth, imgLayerHeight: integer;
*)
ImageEnMView1.SelectImage(0);
with ImageEnView1 do
begin
ImageEnMView2.SelectImage(0);
with CurrentLayer do
begin
imgLayerLeft := PosX;
imgLayerTop := PosY;
imgLayerWidth := Width;
imgLayerHeight := Height;
end;
ImageEnMView1.SelectImage(0);
with CurrentLayer do
begin
imgBackgroundLeft := PosX;
imgBackgroundTop := PosY;
imgBackgroundWidth := Width;
imgBackgroundWidth := Height;
end;
end;
ShowMessage('Total will be created: '+ IntToStr(cntCombinations)+ ' images');
for layer := 0 to cntBackground -1 do
begin
// here recursive change layer
ImageEnMView2.SelectImage(layer);
// change size and position layer
with ImageEnView1 do
begin
with CurrentLayer do
begin
PosX := imgLayerLeft;
PosY := imgLayerTop;
Width := imgLayerWidth;
Height := imgLayerHeight;
end;
end;
for background := 0 to cntLayers -1 do
begin
// here recursive change background
ImageEnMView1.SelectImage(background);
// change size and position background
with ImageEnView1 do
begin
with CurrentLayer do
begin
PosX := imgBackgroundLeft;
PosY := imgBackgroundTop;
Width := imgBackgroundWidth;
Height := imgBackgroundHeight;
end;
end;
// here recursive saved combinations
//ImageEnMView2 selected image name + ' ' + ImageEnMView1 selected image name + ExtName
ImageEnView1.LayersSaveMergedTo('');
end;
end;
end;
procedure TfrmMain.ImageEnMView1ImageSelect(Sender: TObject; idx: Integer);
begin
with ImageEnView1 do
begin
LayersCurrent := idx;
end;
end;
procedure TfrmMain.ImageEnMView2ImageSelect(Sender: TObject; idx: Integer);
begin
with ImageEnView1 do
begin
LayersCurrent := idx;
end;
end;
end.