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
+13.6k Golang : reCAPTCHA example
+16.4k Golang : Send email and SMTP configuration example
+8.3k Golang : Number guessing game with user input verification example
+9.4k Golang : Web(Javascript) to server-side websocket example
+10.3k Golang : Embed secret text string into binary(executable) file
+11.6k Swift : Convert (cast) Float to String
+14.5k Golang : Overwrite previous output with count down timer
+7.7k Gogland : Where to put source code files in package directory for rookie
+36.3k Golang : Convert(cast) int64 to string
+6.9k Golang : Fibonacci number generator examples
+26.1k Mac/Linux and Golang : Fix bind: address already in use error