From Directorforum Collaboration Wiki
-- Description:
-- converts 32 bit image to grayscale
-- Parameters:
-- _image = 32 bit image
-- Note:
-- #grayscale can be replaced by any custom color palette, (sepia can be useful too)
on convertToGrayScale _image
gray = image(_image.width, _image.height, 8,#grayscale)
gray.copyPixels(_image, _image.rect, _image.rect , [#ink:#copy])
if _image.usealpha =0 then return gray -- not 32 bit image skipping copying
i32 = image(_image.width, _image.height, 32)
i32=_image.duplicate()
i32.copyPixels(gray, i32.rect, i32.rect , [#ink:#copy,#mask:_image.extractALpha()])
i32.setalpha(_image.extractALpha())
return i32
end