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
+10.8k Golang : Command line file upload program to server example
+13k Golang : Calculate elapsed years or months since a date
+7k Golang : Takes a plural word and makes it singular
+5.3k Golang : How to deal with configuration data?
+9.2k Golang : Create and shuffle deck of cards example
+6.1k Golang : Debug with Godebug
+32.7k Golang : Regular Expression for alphanumeric and underscore
+15k Golang : How do I get the local IP (non-loopback) address ?
+6.9k Mac OSX : Find large files by size
+6.2k Golang : Get Hokkien(福建话)/Min-nan(閩南語) Pronounciations
+6.7k Golang : When to use make or new?
+19.9k Golang : Measure http.Get() execution time