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

http://golang.org/pkg/image/#Paletted.Bounds

http://golang.org/pkg/image/#Paletted.ColorIndexAt

Advertisement