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
 How to remove all Layers of certain type?

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 - Jul 26 2016 : 11:35:48
Hello,

I want to remove all Mask Layers from a file which contains around 59 layers in all. From these 16 layers are Mask Layers.

For this I am using a for loop from 1 to layers count.

But as the value of loop count goes higher I am getting out of bounce error.

I also ties to run the loop in reverse but that also did not work.

What is the easy way to do this?

TIA


Yogi Yang
3   L A T E S T    R E P L I E S    (Newest First)
yogiyang Posted - Jul 27 2016 : 08:28:05
Bill and Nigel,

Thanks for the feedback.

Actually I was going out of office so I posted the query in a hurry and forgot to post the code.

But now with the help of Bills code I have managed to solve the problem.

Thanks again.

Regards,


Yogi Yang
xequte Posted - Jul 26 2016 : 18:12:51
Thanks Bill

You can also check the IsMask property:

   if ImageEnView.CurrentLayer.IsMask then
     ImageEnView.LayersRemove(i);


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Jul 26 2016 : 11:54:39
You probably can do this by giving each MaskLayer a LayerName when the layer is created and then iterate though the layers backwards to identify the mask layers.

Add Mask Layer
iLayer := ImageEnView.LayersAdd;
ImageEnView.Layers[iLayer].Name := AnsiString('Mask Layer');

Remove all Mask Layers
for i := ImageEnView.LayersCount - 1 downto 1 do
  begin
   ImageEnView.LayersCurrent := i;
   if ImageEnView.CurrentLayer.Name := AnsiString('Mask Layer') then
     ImageEnView.LayersRemove(i);
  end;
ImageEnView.Update;

You must iterate backwards because you are removing layers. If you iterate forwards then the loop becomes corrupted which will cause an exception. Do not include layer 0 because that is not a mask layer.

I can not comment more because you did not show any code at all.

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