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
+7.3k Golang : How to iterate a slice without using for loop?
+14k Golang : Fix cannot use buffer (type bytes.Buffer) as type io.Writer(Write method has pointer receiver) error
+8.1k Golang : How To Use Panic and Recover
+11.5k Golang : Generate DSA private, public key and PEM files example
+8.4k Golang : Generate Datamatrix barcode
+51.9k Golang : How to get time in milliseconds?
+8.4k Golang : Convert word to its plural form example
+9.7k Golang : Load ASN1 encoded DSA public key PEM file example
+6.4k Golang : Break string into a slice of characters example
+3.7k Golang : Switch Redis database redis.NewClient
+7k Golang : Takes a plural word and makes it singular
+10.8k PHP : Convert(cast) bigInt to string