< Previous | Contents | Next >

Process

This Process function shows expanded Image creation to define extra channels so there are 8 channels RGBA and Bg-RGBA.

image


NOTE That any number variables using any name can be passed to the functions, these do not have to be declared. In this case 3 variables gain, bright, var_C {gain = 2.0, bright=-0.3, var_C=1.5} are passed to the function.

MultiProcessPixels will use the defined function and apply it to the images.



function Process(req)

local img1 = InImage1:GetValue(req) local img2 = InImage2:GetValue(req)

local operation = InOperation:GetValue(req).Value+1 if img2 == nil then

img2 = img1

end

--This creates an image with 4 extra channels for function 5 local imgattrs = {

IMG_Document = self.Comp,

{ IMG_Channel = "Red", },

{ IMG_Channel = "Green", },

{ IMG_Channel = "Blue", },

{ IMG_Channel = "Alpha", },

{ IMG_Channel = "BgRed", },

{ IMG_Channel = "BgGreen", },

{ IMG_Channel = "BgBlue", },

{ IMG_Channel = "BgAlpha", }, IMG_Width = img1.Width, IMG_Height = img1.Height, IMG_XScale = img1.XAspect, IMG_YScale = img1.YAspect,

IMAT_OriginalWidth = img1.realwidth, IMAT_OriginalHeight = img1.realheight, IMG_Quality = not req:IsQuick(), IMG_MotionBlurQuality = not req:IsNoMotionBlur(),

}

if not req:IsStampOnly() then imgattrs.IMG_ProxyScale = 1

end

if SourceDepth ~= 0 then imgattrs.IMG_Depth = SourceDepth

end

local out = Image(imgattrs)


local func = op_funcs[operation] -- get pointer to the function from the table


-- Must have a valid operation function, and images must be same dimensions

if func and (img1.Width == img2.Width) and (img1.Height == img2.Height) then out = Image({IMG_Like = img1})


out:MultiProcessPixels(nil, {gain = 2.0, bright=-0.3, var_C=1.5}, 0,0, img1.Width, img1.Height, img1, img2, func)

end

OutImage:Set(req, out)

end