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
+9k Golang : Populate or initialize struct with values example
+15.9k Golang : Update database with GORM example
+31.7k Golang : How to convert(cast) string to IP address?
+5.8k Cash Flow : 50 days to pay your credit card debt
+9.3k Golang : How to get username from email address
+35.9k Golang : Integer is between a range
+12.3k Golang : Print UTF-8 fonts on image example
+12.2k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+31.6k Golang : Get local IP and MAC address
+5.8k Golang : Fix opencv.LoadHaarClassifierCascade The node does not represent a user object error
+4.9k Python : Find out the variable type and determine the type with simple test
+5.7k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example