picturetograyscale.lua 349 B

123456789101112
  1. -- picture to grayscale - from Paulo Silva, july 2012 - gpl licence
  2. w,h=getpicturesize()
  3. function grayscaleindexed(c)
  4. r,g,b=getcolor(c);return math.floor((b*11+r*30+g*59)/100);end
  5. for y=0,h-1,1 do
  6. for x=0,w-1,1 do
  7. u=getpicturepixel(x,y)
  8. k=grayscaleindexed(u)
  9. putpicturepixel(x,y,k)
  10. end;end
  11. for c=0,255,1 do setcolor(c,c,c,c);end