Golang image.Paletted.Set and SetColorIndex functions example
package image
Golang image.Paletted.Set and SetColorIndex functions usage example
package main
import (
"image"
"image/color"
"math/rand"
)
func main() {
p := color.Palette{color.NRGBA{0xf0, 0xf0, 0xf0, 0xff}}
rect := image.Rect(0, 0, 100, 100)
paletted := image.NewPaletted(rect, p)
paletted.Set(10,10, color.RGBA{0, 0, 0, 255}) // black for example
colorIndex := uint8(rand.Int())
paletted.SetColorIndex(10, 10, colorIndex)
}
References :
Advertisement
Something interesting
Tutorials
+5.2k Golang : How to solve "too many .rsrc sections" error?
+3.5k Java : Generate multiplication table example
+6.7k Golang : Test if an input is an Armstrong number example
+4.1k Unix/Linux : secure copying between servers with SCP command examples
+10.7k Golang : md5 hash of a string
+17.5k Golang : Get host name or domain name from IP address
+26.6k Golang : Change a file last modified date and time
+5.1k Golang : Selection sort example
+8.4k Golang : Quadratic example
+28.6k Golang : How to get HTTP request header information?