If you want to convert a lot of files in a batch process, you can do something like this:
local dir = LoadDir("mask")
for n = 1, #dir do
collectgarbage()
local pixmap = LoadPixmap("mask/"..dir[n])
if pixmap ~= nil then
local x, y, r, g, b, a
for x = 0, pixmap.size.x - 1 do
for y = 0, pixmap.size.y - 1 do
local rgba = pixmap:ReadPixel(x, y)
r = Red(rgba)
g = Green(rgba)
b = Blue(rgba)
a = Alpha(rgba)
rgba = Rgba(g, 255 - a, r, 255)
pixmap:WritePixel(x, y, rgba)
end
end
pixmap:Save("mask/"..dir[n])
end
end