ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to resize a group of layers programmatically?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
727 Posts

Posted - Jun 03 2016 :  08:59:33  Show Profile  Reply
Hello,

There is facility to select multiple layers and group them.

Is there a way to resize, rotate, etc. the whole group programmatically?

TIA


Yogi Yang

w2m

USA
1990 Posts

Posted - Jun 03 2016 :  10:05:17  Show Profile  Reply
procedure TForm1.MultipleLayerSelection1Click(Sender: TObject);
{ Toggle selecting multiple layers }
begin
  if MultipleLayerSelection1.Checked then
    ImageEnView1.LayerOptions := ImageEnView1.LayerOptions +
      [loAllowMultiSelect]
  else
    ImageEnView1.LayerOptions := ImageEnView1.LayerOptions -
      [loAllowMultiSelect];
end;

procedure TForm1.GroupLayers1Click(Sender: TObject);
{ Toggle Grouping Layers }
begin
  if GroupLayers1.Down then
  begin
    ImageEnView1.LayersGroup(true);
    ImageEnView1.LayersDeselectAll;
    Layers1.ItemIndex := 0;
    GroupLayers1.Caption := 'Ungroup Layers';
  end
  else
  begin
    ImageEnView1.LayersUngroup();
    ImageEnView1.LayersDeselectAll;
    Layers1.ItemIndex := 0;
    GroupLayers1.Caption := 'Group Layers';
  end;
end;

procedure TForm1.ResizeAllLayers1Click(Sender: TObject);
{ Resize all selected layers }
begin
  {Halve the size of all layers}
  ImageEnView1.LayersSizeAll(0.5, 0.5);
end;

procedure TForm1.RotateAllLayers1Click(Sender: TObject);
{ Rotate all selected layers }
begin
  {Rotate all layers 45° clockwise}
  ImageEnView1.LayersRotateAll(315);
end;

procedure TForm1.ResizeSelectedLayers1Click(Sender: TObject);
{ Resize all selected layers }
var
  i: Integer;
begin
  ImageEnView1.LockUpdate;
  for i := 0 to ImageEnView1.LayersCount - 1 do
    if ImageEnView1.Layers[i].Selected then
    begin
      ImageEnView1.Layers[i].Width := ImageEnView1.Layers[i].Width div 2;
      ImageEnView1.Layers[i].Height := ImageEnView1.Layers[i].Height div 2;
      ImageEnView1.LayersFixSizes(i);
    end;
  ImageEnView1.UnlockUpdate;
end;

procedure TForm1.RotateSelectedLayers1Click(Sender: TObject);
{ Rotate all selected layers }
var
  i: Integer;
begin
  ImageEnView1.LockUpdate;
  for i := 0 to ImageEnView1.LayersCount - 1 do
    if ImageEnView1.Layers[i].Selected then
      ImageEnView1.Layers[i].Rotate := 90;
  ImageEnView1.LayersFixRotations(LYR_SELECTED_LAYERS);
  ImageEnView1.UnlockUpdate;
end;

1. Add a background image
2. Add two layers
3. Click MultipleLayerSelection1 checkbox
4. Click GroupLayers1 SpeedButton
5. Select ResizeAllLayers1 button or select RotateAllLayers1 button or select ResizeSelectedLayers1 button or select RotateSelectedLayers1 button

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

yogiyang

India
727 Posts

Posted - Jun 04 2016 :  01:18:38  Show Profile  Reply
Hello Bill,

Thank you for the code sample.

But I am not able to find any documentation on function/procedures you have used in your code like for example: LayersSizeAll

Another thing I am using IE 6.2.1 as I am not able to compile our flagship product in 6.3.0 for some unknown reasons.

Tia


Yogi Yang
Go to Top of Page

w2m

USA
1990 Posts

Posted - Jun 04 2016 :  11:12:06  Show Profile  Reply
Put the cursor on LayersSizeAll... ImageEnView1.LayersSizeAll(0.5, 0.5); then right click to popup a menu then select Find Declaration. The help information will be located just before the procedure or function in the source code. This means your help file is not current. Update your help file.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

xequte

38615 Posts

Posted - Jun 04 2016 :  17:05:46  Show Profile  Reply
Hi

Breaking changes between 6.2.2 and 6.3.0 were minimal (affecting certain undo/redo calls):

http://www.imageen.com/help/Updating%20and%20Compatibility.html

So can you give us more detail of your problems with v6.3.0?


You can see documentation for the methods that Bill mentions at:

http://www.imageen.com/help/TImageEnView.html


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

harry stahl

Germany
62 Posts

Posted - Jul 17 2016 :  16:21:22  Show Profile  Reply
One Remark to LayersSizeAll. When I have the following Photoshop-Layerfile:



And after using "ImageEnView1.LayersSizeAll(scaleX, ScaleY, false, True);" (where ScaleX and ScaleY = 0.5):



The Sizes are OK, but the layers are on the wrong positions.

I have this solution for me, that works (Resizing all Layers):

  ImageEnView1.LockUpdate;
  for i := 0 to ImageEnView1.LayersCount - 1 do
    begin
      ImageEnView1.Layers[i].Width := round (ImageEnView1.Layers[i].Width * ScaleX);
      ImageEnView1.Layers[i].Height := round (ImageEnView1.Layers[i].Height * ScaleY);

      ImageEnView1.Layers[i].PosX := Round (ImageEnView1.Layers[i].posx * ScaleX);
      ImageEnView1.Layers[i].PosY := round (ImageEnView1.Layers[i].posy * ScaleY);

      if i = 0 then ImageEnView1.LayersFixSizes(i);
    end;
    ImageEnView1.UnlockUpdate;
    ImageEnview1.Update;


Perhaps could this be optimized / fixed in the next update.

HS
Go to Top of Page

xequte

38615 Posts

Posted - Jul 18 2016 :  20:25:17  Show Profile  Reply
Thanks,

I've added ScalePosition as a parameter in v6.3.1.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: