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
+4.6k Mac OSX : Get disk partitions' size, type and name
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+8.3k Golang: Prevent over writing file with md5 hash
+33.9k Golang : Call a function after some delay(time.Sleep and Tick)
+36.3k Golang : Convert(cast) int64 to string
+25k Golang : Create PDF file from HTML file
+36.5k Golang : Save image to PNG, JPEG or GIF format.
+5.2k PHP : See installed compiled-in-modules
+51.4k Golang : Check if item is in slice/array
+9.1k Golang : How to capture return values from goroutines?
+6.7k Golang : Humanize and Titleize functions
+9k Golang : Get SPF and DMARC from email headers to fight spam