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
 Arrange Layers based on First layers orientation
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
725 Posts

Posted - Sep 04 2017 :  06:40:15  Show Profile  Reply
Hello,

I have a need to arrange three layers which are loaded using files selected by user.

Base on the photo loaded in first layer (layer 1 not layer 0) I need to arrange the other layers.

Currently my layers are getting arranged uniformly like this (in 1024x768 size):


If above image is observed then you will notice that the first loaded photo is having portrait orientation so the arrangement should be like this:


What would be the best way to achieve this. Here the number of photos a user can load would be any thing between 1 to 8.

TIA


Yogi Yang

xequte

38221 Posts

Posted - Sep 04 2017 :  22:40:45  Show Profile  Reply
Hi Yogi

I'm not sure of any easy solution to this, other than a set of pre-defined layouts, but with up to eight images of either portrait or landscape, there are probably too many variations.

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

w2m

USA
1990 Posts

Posted - Sep 05 2017 :  10:36:25  Show Profile  Reply
All you have to do is depending on the number of layers is to position and set the dimensions of each layer accordingly.
The following code creates a 3 image layout as you specified. You will have to modify this to create other layouts.
Only you can do this because only you know what the layouts should look like.
This code does not attempt to determine the orientation, it merely shows how to show the layers as you indicated in your post.
You can determine the orientation by comparing the IEBitmap.Width and IEBitmap.Height and adjust the code accordingly.
procedure TForm1.Preview1Click(Sender: TObject);
var
  i: Integer;
  iCount: Integer;
  iLayer: Integer;
  iMidPointX: Integer;
  iMidPointY: Integer;
  iWidth: Integer;
  iHeight: Integer;
  iMarginX: Integer;
  iMarginY: Integer;
  iZoom: Double;
begin
  iCount := ImageEnMView1.ImageCount;
  if iCount > 0 then
  begin
    ImageEnView1.Proc.ImageResize(1024, 768);
    ImageEnView1.Proc.Fill(clWhite);
    iWidth := ImageEnView1.Layers[0].Width;
    iHeight := ImageEnView1.Layers[0].Height;
    iMarginX := 10;
    iMarginY := 10;
    iMidPointX := iWidth div 2;
    iMidPointY := iHeight div 2;
    iCount := ImageEnMView1.ImageCount;
    iZoom := ImageEnView1.Zoom;
    for i := 1 to iCount do
    begin
      iLayer := ImageEnView1.LayersAdd;
      ImageEnMView1.CopyToIEBitmap(iLayer - 1, ImageEnView1.IEBitmap);
      ImageEnView1.Update;
      ImageEnView1.Layers[iLayer].Name := 'Image Layer ' + IntToStr(i);
      if i = 1 then
      begin
        ImageEnView1.Layers[iLayer].PosX := iMarginX;
        ImageEnView1.Layers[iLayer].PosY := iMarginY;
        ImageEnView1.Layers[iLayer].Width := iMidPointX - iMarginX * 2;
        ImageEnView1.Layers[iLayer].Height := iMidPointY - iMarginY;
      end;
      if i = 2 then
      begin
        ImageEnView1.Layers[iLayer].Width := iMidPointX - iMarginX * 2;
        ImageEnView1.Layers[iLayer].Height := iMidPointY - iMarginY * 2;
        ImageEnView1.Layers[iLayer].PosX := iMarginX;
        ImageEnView1.Layers[iLayer].PosY := iMidPointY + iMarginY;
      end;
      if i = 3 then
      begin
        ImageEnView1.Layers[iLayer].PosX := iMidPointX;
        ImageEnView1.Layers[iLayer].PosY := iMarginY;
        ImageEnView1.Layers[iLayer].Width := iMidPointX - iMarginX;
        ImageEnView1.Layers[iLayer].Height := iHeight - iMarginY * 2;
      end;
      ImageEnView1.Update;
    end;
  end;
end;



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