Golang image.Paletted type and NewPaletted function example
package image
Paletted is an in-memory image of uint8 indices into a given palette.
NewPaletted returns a new Paletted with the given width, height and palette.
Golang image.Paletted type and NewPaletted function usage 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("Pix : ",paletted.Pix)
fmt.Println("Stride : ", paletted.Stride)
fmt.Println("Palette : ", paletted.Palette)
}
Output :
Pix : [0 0 0 ..... 0]
Stride : 100
Palette : [{240 240 240 255}]
References :
Advertisement
Something interesting
Tutorials
+4.6k JavaScript : Rounding number to decimal formats to display currency
+32.2k Golang : Convert []string to []byte examples
+11.1k Golang : Simple image viewer with Go-GTK
+17k Golang : Get number of CPU cores
+6.5k Golang : Map within a map example
+5.7k Linux/Unix/PHP : Restart PHP-FPM
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+5.2k Python : Create Whois client or function example
+41.9k Golang : How do I convert int to uint8?
+5.8k Javascript : How to replace HTML inside <div>?