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
+7.5k Golang : Handling Yes No Quit query input
+5.8k Linux : Disable and enable IPv4 forwarding
+8.8k Golang : Executing and evaluating nested loop in html template
+12.7k Golang : Sort and reverse sort a slice of bytes
+6.9k Golang : How to setup a disk space used monitoring service with Telegram bot
+12.1k Golang : Save webcamera frames to video file
+8.5k Golang : How to check if input string is a word?
+6.1k Golang : Build new URL for named or registered route with Gorilla webtoolkit example
+7.7k Golang : How to execute code at certain day, hour and minute?
+6.1k Java : Human readable password generator
+9.3k Golang : How to get username from email address
+9.6k Golang : Copy map(hash table) example