plugin.go 348 B

1234567891011121314151617
  1. package main
  2. import "image"
  3. // Convert to grayscale image
  4. func Transform(src image.Image) image.Image {
  5. bounds := src.Bounds()
  6. w, h := bounds.Max.X, bounds.Max.Y
  7. ret := image.NewGray(image.Rectangle{image.Point{0, 0}, image.Point{w, h}})
  8. for x := 0; x < w; x++ {
  9. for y := 0; y < h; y++ {
  10. ret.Set(x, y, src.At(x, y))
  11. }
  12. }
  13. return ret
  14. }