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
+8.7k Golang : How to join strings?
+6.7k Golang : Output or print out JSON stream/encoded data
+29.4k Golang : JQuery AJAX post data to server and send data back to client example
+48.1k Golang : How to convert JSON string to map and slice
+9.3k Golang : Generate random Chinese, Japanese, Korean and other runes
+6.2k Golang : Process non-XML/JSON formatted ASCII text file example
+9.6k Javascript : Read/parse JSON data from HTTP response
+6.3k Golang : Extract sub-strings
+31.5k Golang : bufio.NewReader.ReadLine to read file line by line
+16.8k Golang : Get own process identifier
+19.2k Golang : Delete item from slice based on index/key position
+10.2k Golang : How to profile or log time spend on execution?