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
+13.6k Golang : reCAPTCHA example
+7.2k Golang : Null and nil value
+9.2k Golang : How to control fmt or log print format?
+12.3k Golang : Print UTF-8 fonts on image example
+19.2k Golang : Check if directory exist and create if does not exist
+14.3k Golang : Recombine chunked files example
+16.3k Golang : convert string or integer to big.Int type
+15.6k Golang : rune literal not terminated error
+6.4k CodeIgniter : form input set_value cause " to become & quot
+19.5k Golang : Example for DSA(Digital Signature Algorithm) package functions
+5.7k Get website traffic ranking with Similar Web or Alexa
+26.9k Golang : Force your program to run with root permissions