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
+47.8k Golang : Convert int to byte array([]byte)
+4.9k Python : Find out the variable type and determine the type with simple test
+5.6k Swift : Get substring with rangeOfString() function example
+7.4k Golang : Hue, Saturation and Value(HSV) with OpenCV example
+13.1k Golang : How to get a user home directory path?
+5.2k Golang : Calculate half life decay example
+16.4k Golang : Convert slice to array
+5.6k Unix/Linux : How to find out the hard disk size?
+9.4k Android Studio : Indicate progression with ProgressBar example
+6.1k Golang : How to write backslash in string?
+5.7k Fix yum-complete-transaction error
+9.1k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference