Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How to 'invert' an image? Blend mode amusements. — Gideros Forum

How to 'invert' an image? Blend mode amusements.

AniketAniket Member
edited August 2014 in General questions
I have an image which is mostly transparent with a bit of white on it, I'd like to make it transparent where it was white and white where it was transparent. How can I do that ?

I really don't get blend modes.

Comments

  • How about this:
    local media = Media.new(e.path)
    for i = 1, media:getWidth() do
        for j = 1, media:getHeight() do
            local r, g, b, a = media:getPixel(i, j)
            if a == 0 then --transparent
                media:setPixel(i, j, 255, 255, 255, 1)
            elseif r == 255 and g == 255 and b == 255 then
                media:setPixel(i, j, 255, 255, 255, 0)
            end
        end
    end
    +1 -1 (+3 / -0 )Share on Facebook
Sign In or Register to comment.