Code: Select all
function invertImage(theImage)
newImage = Image.createEmpty(theImage:height(), theImage:width())
for x = 1, theImage:width()-1 do
for y = 1, theImage:height()-1 do
p = theImage:pixel(y, x)
c = Color.new(255-p:colors().r,255-p:colors().g,255-p:colors().b)
newImage:pixel(y, x, c)
end
end
return newImage
end
test = Image.load("test.png")
p = test:pixel(0, 0)
screen:blit(40, 36, test)
screen:blit(240, 36, invertImage(test))
screen:print(40, 26, "Original", Color.new(255, 255, 255))
screen:print(240, 26, "Inverted", Color.new(255, 255, 255))
screen:print(207, 244, "Invert Function by flattspott", Color.new(255, 255, 255))
screen:flip()
screen.waitVblankStart(600)
The screenshot: