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
+9.4k Golang : How to get ECDSA curve and parameters data?
+19.3k Golang : Delete item from slice based on index/key position
+11.8k How to tell if a binary(executable) file or web application is built with Golang?
+11.7k Golang : Simple file scaning and remove virus example
+18.8k Unmarshal/Load CSV record into struct in Go
+5.4k Golang : Get FX sentiment from website example
+14.1k Golang: Pad right or print ending(suffix) zero or spaces in fmt.Printf example
+11.7k Golang : Surveillance with web camera and OpenCV
+46.6k Golang : Encode image to base64 example
+9.5k Mac OSX : Get a process/daemon status information
+10.7k Golang : Allow Cross-Origin Resource Sharing request
+32.6k Golang : Copy directory - including sub-directories and files