on rgbToGrayscaleImageFast (img) res = image(img.width, img.height, 8) res.paletteRef = #grayScale res.copyPixels(img, img.rect, img.rect) return res end on rgbToGrayscaleImageCustom (img) res = image(img.width, img.height, 8) res.paletteRef = #grayScale repeat with x = 0 to img.width-1 repeat with y = 0 to img.height-1 c = img.getPixel(x,y) n = c.red*0.2126 + c.green*0.7152 + c.blue*0.0722 res.setPixel(x,y, color(256-n)) end repeat end repeat return res end