Golang image.Gray.At function example
package image
func (p *Gray) At(x, y int) color.Color
Golang image.Gray.At function usage example
package main
import (
"fmt"
"image"
"image/png"
"os"
)
func init() {
image.RegisterFormat("png", "png", png.Decode, png.DecodeConfig)
}
func main() {
imgfile, err := os.Open("./img.png")
if err != nil {
fmt.Println("img.png file not found!")
os.Exit(1)
}
defer imgfile.Close()
img, _, err := image.Decode(imgfile)
bounds := img.Bounds()
grayrect := image.NewGray(bounds) // <-- here
// see http://golang.org/pkg/image/color/#Color
color := grayrect.At(100, 100) // <--- HERE
fmt.Println(color)
fmt.Println(color.RGBA())
}
Reference :
Advertisement
Something interesting
Tutorials
+17.4k Golang : Get future or past hours, minutes or seconds
+9.2k Golang : How to control fmt or log print format?
+15.3k Golang : How to get Unix file descriptor for console and file
+19.6k Golang : Set or Add HTTP Request Headers
+5.3k Javascript : Shuffle or randomize array example
+33.6k Golang : How to check if slice or array is empty?
+10.1k Golang : How to tokenize source code with text/scanner package?
+16k Golang : Generate universally unique identifier(UUID) example
+5.4k Golang : Return multiple values from function
+24.5k Golang : Change file read or write permission example
+7.4k Golang : How to detect if a sentence ends with a punctuation?
+10.2k Golang : Use regular expression to get all upper case or lower case characters example