Script, Transfer image layer to alpha layer - RealWorld forums

Log-in or register.

Script, Transfer image layer to alpha layer

jediYellow
on October 21st 2022

Transfers the color of one layer to the alpha of another layer, creating a new layer with the result. --Vlasta wrote this for me some time back. ;|

"Configuration"

Context;
var li = Document.LayeredImage;
var n = li.Layers;
var names = [];
for (var i = 0; i < n; ++i)
{
	names[i] = li.GetLayerName(i);
}
Configuration.Add1ofNPicker("l1", "Icon Layer", "Layer that recieves the
transfer", names, 0);
Configuration.Add1ofNPicker("l2", "Texture Layer", "Layer with the image to
transfer", names, n > 1 ? 1 : 0);

"Execution"

Context;
var li = Document.LayeredImage;
var nX = li.sizeX;
var nY = li.sizeY;
var n = li.Layers;
var l1 = li.GetLayer(Configuration.l1);
var l2 = li.GetLayer(Configuration.l2);
// create new layer
var wiz = Application.CreateWizard("35AFBDB5-1B26-4195-8786-83C8E1CBC08E");
wiz.SizeX = nX;
wiz.SizeY = nY;
li.CreateLayer(-1, wiz); // "35AFBDB5-1B26-4195-8786-83C8E1CBC08E");
var newlayer = li.GetLayer(0);
// copy l2 to new layer
Blender.Compose(newlayer, 0, 0, nX, nY, l2, 0, 0, 0, Blender.OpSrc);
// copy alpha channer from l1 to the new layer
Blender.Compose(newlayer, 0, 0, nX, nY, l1, 0, 0, 0, Blender.OpMapChannels,
	Blender.MapChannels(Blender.ChEmpty, Blender.ChEmpty, Blender.ChEmpty,
Blender.ChA, Blender.ChEmpty, Blender.ChEmpty, Blender.ChEmpty, Blender.ChA));
Page views: 349       Posts: 1      
What about ICL files?
Select background
I wish there were...