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
+17.9k Golang : Qt image viewer example
+8.8k Golang : On lambda, anonymous, inline functions and function literals
+4.9k Javascript : How to get width and height of a div?
+12.3k Golang : Print UTF-8 fonts on image example
+5.9k Golang : Denco multiplexer example
+36.3k Golang : Convert(cast) int64 to string
+14k Golang : Compress and decompress file with compress/flate example
+16.5k Golang : Execute terminal command to remote machine example
+15.9k Golang : Read a file line by line
+16.1k Golang : How to check if input from os.Args is integer?
+5.5k Clean up Visual Studio For Mac installation failed disk full problem
+4.9k Unix/Linux : secure copying between servers with SCP command examples