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
+18.8k Golang : Delete duplicate items from a slice/array
+7.3k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+4.7k Chrome : How to block socketloop.com links in Google SERP?
+6.4k Golang : Break string into a slice of characters example
+6.8k Swift : substringWithRange() function example
+14.4k Golang : Parsing or breaking down URL
+21.2k Golang : How to get time zone and load different time zone?
+5.8k Golang : Find change in a combination of coins example
+29.5k Golang : Saving(serializing) and reading file with GOB
+8.3k Useful methods to access blocked websites
+3.6k Java : Get FX sentiment from website example
+9.5k Golang : Extract or copy items from map based on value