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
+14.2k Golang : Chunk split or divide a string into smaller chunk example
+7.9k Golang : Ways to recover memory during run time.
+11.5k Golang : Generate DSA private, public key and PEM files example
+9.1k Golang : Simple histogram example
+12k Golang : Clean formatting/indenting or pretty print JSON result
+13.5k Golang : How to get year, month and day?
+4.7k Adding Skype actions such as call and chat into web page examples
+5.6k Golang : Shortening import identifier
+18.1k Golang : Convert IPv4 address to decimal number(base 10) or integer
+12.7k Golang : zlib compress file example
+39.2k Golang : How to read CSV file