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
+5.4k Javascript : How to loop over and parse JSON data?
+6.7k Golang : Skip or discard items of non-interest when iterating example
+5.9k Golang : Detect variable or constant type
+8.2k Golang : Get final or effective URL with Request.URL example
+20.9k Golang : Underscore or snake_case to camel case example
+8.8k Golang : Accept any number of function arguments with three dots(...)
+21.1k Golang : For loop continue,break and range
+6.3k Golang : Calculate US Dollar Index (DXY)
+17.9k Golang : How to make a file read only and set it to writable again?
+6.2k Golang & Javascript : How to save cropped image to file on server
+6.1k Golang : How to write backslash in string?