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
+28.5k Golang : Change a file last modified date and time
+13.4k Golang : Read from buffered reader until specific number of bytes
+6.2k Golang : Get Hokkien(福建话)/Min-nan(閩南語) Pronounciations
+18.9k Golang : Read input from console line
+5.4k Golang : fmt.Println prints out empty data from struct
+5.2k PHP : See installed compiled-in-modules
+29.5k Golang : Saving(serializing) and reading file with GOB
+29.3k Golang : Save map/struct to JSON or XML file
+5.8k Golang : Fix opencv.LoadHaarClassifierCascade The node does not represent a user object error
+15.6k Golang : How to convert(cast) IP address to string?
+21.2k Golang : Clean up null characters from input data