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
+12.3k Golang : How to display image file or expose CSS, JS files from localhost?
+11.6k Swift : Convert (cast) Float to String
+9.1k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+23.7k Find and replace a character in a string in Go
+7.5k Golang : Rot13 and Rot5 algorithms example
+5.9k Golang : Extract unicode string from another unicode string example
+17.9k Golang : Login and logout a user after password verification and redirect example
+5k Google : Block or disable caching of your website content
+9.2k Golang : Create and shuffle deck of cards example
+6.2k Golang : Get Hokkien(福建话)/Min-nan(閩南語) Pronounciations
+17.9k Golang : How to make a file read only and set it to writable again?