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 : syscall.Socket example
+22.7k Golang : Set and Get HTTP request headers example
+10.1k Golang : Edge detection with Sobel method
+19.4k Golang : Fix cannot download, $GOPATH not set error
+7.4k Golang : Word limiter example
+4.6k MariaDB/MySQL : How to get version information
+16.3k Golang : Find out mime type from bytes in buffer
+7.1k Golang : A simple forex opportunities scanner
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+7.1k Golang : Squaring elements in array
+13.1k Golang : List objects in AWS S3 bucket
+17.8k Golang : Iterate linked list example