I am trying to create a new Color object using the RGB values ββthat I have in the variables:
http://golang.org/pkg/image/color/
package main import ( "fmt" "image" _ "image/gif" _ "image/jpeg" _ "image/png" "os" ) func main() { reader, err := os.Open("test-image.jpg") if err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) } image, _, err := image.Decode(reader) if err != nil { fmt.Fprintf(os.Stderr, "%s", err) } bounds := image.Bounds() for i := 0; i <= bounds.Max.X; i++ { for j := 0; j <= bounds.Max.Y; j++ { pixel := image.At(i, j) if i == 0 && j == 0 { red, green, blue, _ := pixel.RGBA() averaged := (red + green + blue) / 3
I cannot find any Function package that generates a new Color object based on rgba values.
Any recommendations?
source share