Golang image.Paletted.At, Bounds and ColorIndex functions example
package image
Golang image.Paletted.At, Bounds and ColorIndex functions example
package main
import (
"fmt"
"image"
"image/color"
)
func main() {
p := color.Palette{color.NRGBA{0xf0, 0xf0, 0xf0, 0xff}}
rect := image.Rect(0, 0, 100, 100)
paletted := image.NewPaletted(rect, p)
fmt.Println("At : ",paletted.At(10,10))
fmt.Println("Bounds : ", paletted.Bounds())
fmt.Println("ColorIndexAt : ", paletted.ColorIndexAt(10,10))
}
Output :
At : {240 240 240 255}
Bounds : (0,0)-(100,100)
ColorIndexAt : 0
References :
http://golang.org/pkg/image/#Paletted.At
Advertisement
Something interesting
Tutorials
+9.9k Golang : Turn string or text file into slice example
+9.4k Golang : Find the length of big.Int variable example
+8.1k Golang : Randomize letters from a string example
+16.5k Golang : File path independent of Operating System
+13.4k Golang : Verify token from Google Authenticator App
+5.2k Golang : Experimental Jawi programming language
+6.7k Golang : Humanize and Titleize functions
+6.7k Golang : Derive cryptographic key from passwords with Argon2
+10.8k Golang : Command line file upload program to server example