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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Can we make this... better... ?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
yogiyang Posted - Mar 26 2016 : 02:23:38
Hello,

I am using following code to load Mask in ImageEnView based on what is selected by user in ImageEnMView.

Please suggest improvements.

Here is the code:
if ImageEnView1.IsEmpty then
  begin
    exit;
  end;

  ImageEnView1.LockUpdate;
  if iemMasks.SelectedImage >= 0 then
  begin
    fName := iemMasks.ImageFileName[iemMasks.SelectedImage];
    if FileExists(fName) then
    begin
      Screen.Cursor := crHourGlass;
      LL := ImageEnView1.CurrentLayer.PosX;
      LT := ImageEnView1.CurrentLayer.PosY;
      LW := ImageEnView1.CurrentLayer.Width;
      LH := ImageEnView1.CurrentLayer.Height;
      if ImageEnView1.CurrentLayer.IsMask then
      begin
        idx := ImageEnView1.LayersCurrent;
        MyCurrLayer := idx;
        ImageEnView1.LayersAdd;
        ImageEnView1.LayersMove(ImageEnView1.LayersCurrent, idx);
        ImageEnView1.IO.LoadFromFile(fName);
        ImageEnView1.Proc.Resample(LW + 5, LH + 5, TResampleFilter(4));
        ImageEnView1.CurrentLayer.PosX := LL; // + 5;
        ImageEnView1.CurrentLayer.PosY := LT; // + 5;
        ImageEnView1.CurrentLayer.Width := LW;
        ImageEnView1.CurrentLayer.Height := LH;
        ImageEnView1.Proc.SaveUndo();
        ImageEnView1.LayersRemove(idx + 1);
        ImageEnView1.CurrentLayer.Visible := True;
        ImageEnView1.CurrentLayer.IsMask := True;
        ImageEnView1.CurrentLayer.Visible := False;
        ImageEnView1.Update;
      end
      else // if CurrentLayer.IsMask then
      begin
        idx := ImageEnView1.LayersCurrent;
        MyCurrLayer := idx;
        idx := idx + 1;
        // MainForm.ImageEnViewMain.LockUpdate;
        ImageEnView1.LayersAdd;
        ImageEnView1.IO.LoadFromFile(fName);
        ImageEnView1.Proc.SaveUndo();
        ImageEnView1.Proc.Resample(LW + 5, LH + 5, TResampleFilter(4));
        ImageEnView1.CurrentLayer.PosX := LL + 5;
        ImageEnView1.CurrentLayer.PosY := LT + 5;
        ImageEnView1.CurrentLayer.Width := LW;
        ImageEnView1.CurrentLayer.Height := LH;
        ImageEnView1.Proc.SaveUndo();
        ImageEnView1.LayersMove(ImageEnView1.LayersCurrent, idx);
        ImageEnView1.CurrentLayer.Visible := True;
        ImageEnView1.CurrentLayer.IsMask := True;
        ImageEnView1.CurrentLayer.Visible := False;
        Screen.Cursor := crHourGlass;
      end; // if CurrentLayer.IsMask then
    end
    else // if FileExists(fName) then
    begin
      ShowMessage('Mask file not found. Cannot Open' + #13 + fName);
    end; // if FileExists(fName) then
    ImageEnView1.LayersCurrent := 0;
    Application.ProcessMessages;
    ImageEnView1.LayersCurrent := MyCurrLayer;
  end; // if iemMasks.SelectedImage >= 0 then

  ImageEnView1.UnLockUpdate;
  ImageEnView1.Update;


It seems to work very slowly especially when there are big amount of Layers (50+ layers).

Are there any possibilities to make this code work faster?

TIA


Yogi Yang
4   L A T E S T    R E P L I E S    (Newest First)
yogiyang Posted - Mar 29 2016 : 01:13:59
Hello Nigel,

Thank you for your inputs.

I am not saying it is not performing. What I am saying is that at times when the files in question are very large with more than 80 layers (each having a different content) it seems to take quite a long time.

Otherwise the code is working and we have been using it. We started receiving complains of performance from a few of our users so I posted here.

TIA



Yogi Yang
xequte Posted - Mar 28 2016 : 17:23:43
Hi Yogi

I don't see any particular performance issues in the code, though you do set the Screen.Cursor to crHourGlass and never revert it.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
yogiyang Posted - Mar 28 2016 : 02:33:51
Hello Nigel,

Please find attached a small demo.

I have actually modified the Layers demo so that I don't have to spend time creating a demo from scratch. The code is n XE6.

How to use:
  • Open an image with multiple layers. Preferably a .PSD file.
  • Select a Layer
  • Double click on one of the Mask to apply that mask to selected Layer




attach/yogiyang/201632823220_LayersSample.zip
5307.23 KB


Yogi Yang
xequte Posted - Mar 27 2016 : 21:29:09
Hi Yogi

Can you please upload this as a very simple demo. It will make it easier to optimize.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com