Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Grayscale-image/Lingo/grayscale-image.lingo
Normal file
19
Task/Grayscale-image/Lingo/grayscale-image.lingo
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue