Golang image.NRGBA and NRGBA64.At, ColorModel and Bounds functions example
package image
Golang image.NRGBA and NRGBA64.At, ColorModel and Bounds functions 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()
canvas := image.NewNRGBA(bounds)
fmt.Println(canvas.At(100,100))
fmt.Println(canvas.Bounds())
fmt.Println(canvas.ColorModel())
}
References :
http://golang.org/pkg/image/#NRGBA.At
Advertisement
Something interesting
Tutorials
+10.8k Golang : Natural string sorting example
+7.8k Golang : Load DSA public key from file example
+10.6k Golang : ISO8601 Duration Parser example
+5.8k Golang : Find change in a combination of coins example
+25.6k Golang : convert rune to integer value
+9.2k Golang : does not implement flag.Value (missing Set method)
+5.2k Golang : Issue HTTP commands to server and port example
+28.5k Golang : Change a file last modified date and time
+14k Golang : Human readable time elapsed format such as 5 days ago
+12.8k Swift : Convert (cast) Int or int32 value to CGFloat
+11.2k Golang : Calculate Relative Strength Index(RSI) example
+14.9k Golang : Basic authentication with .htpasswd file