Golang image.NewNRGBA function example
package image
func NewNRGBA(r Rectangle) *NRGBA
NewNRGBA returns a new NRGBA with the given bounds.
Golang image.NewNRGBA function 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)
fmt.Println(img.At(10, 10))
bounds := img.Bounds()
fmt.Println(bounds)
canvas := image.NewNRGBA(bounds) // <-- here
stride := canvas.Stride
fmt.Println("Stride : ", stride)
}
Sample output :
{255 255 255 255}
(0,0)-(600,849)
Stride : 2400
Reference :
Advertisement
Something interesting
Tutorials
+25k Golang : Create PDF file from HTML file
+6.3k Golang : Calculate US Dollar Index (DXY)
+18.5k Golang : Send email with attachment
+17.1k Golang : Capture stdout of a child process and act according to the result
+20.2k Golang : Determine if directory is empty with os.File.Readdir() function
+8.1k Golang : HTTP Server Example
+5.2k Golang : Issue HTTP commands to server and port example
+6.9k Mac OSX : Find large files by size
+8.1k Golang : Append and add item in slice
+7.1k Golang : Get Alexa ranking data example
+8.3k Golang: Prevent over writing file with md5 hash
+18.8k Golang : How to make function callback or pass value from function as parameter?