This behavior composites multiple image objects with alpha but does not suffer from the common problem of the images getting ragged or muddled alphas in the process.
--Copyright 2004-2005
--Chuck Neal
--MediaMacros, Inc.
--Enjoy ;)
on compositeImage vImage, vDestImage, vDestRect, vSourceRect, vBackColor
if vBackCOlor = void then vBackColor = rgb(0,0,0)
iDestImage = vDestImage.duplicate()
--Fill with a solid back color
iDestImage.fill(iDestImage.rect, vBackCOlor)
iSourceImage = vImage.duplicate()
-- get the original alpha channel
iAlphaBuffer = vDestImage.extractAlpha()
--get the composite alpha
if iSourceImage.depth = 32 then
iSourceAlphaBuffer = iSourceImage.extractALpha()
else
--create a new super image alpha
iSourceAlphaBuffer = image(iSourceImage.width, iSourceImage.height, 8, #grayscale)
iSourceAlphaBuffer.fill(iSourceAlphaBuffer.rect, rgb(0,0,0))
end if
--Disable both alphas for the copy pricess
vDestImage.useAlpha = FALSE
iSourceImage.useAlpha = FALSE