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
+19.9k Golang : Count JSON objects and convert to slice/array
+4.8k Which content-type(MIME type) to use for JSON data
+4.6k Linux : sudo yum updates not working
+13k Golang : Calculate elapsed years or months since a date
+18.5k Golang : Aligning strings to right, left and center with fill example
+6.7k Golang : Humanize and Titleize functions
+11.1k Golang : Roll the dice example
+29.5k Golang : Login(Authenticate) with Facebook example
+7.9k Golang : Grayscale Image
+22.1k Golang : Join arrays or slices example
+7k Golang : Levenshtein distance example