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 : Flush and close file created by os.Create and bufio.NewWriter example
+25.4k Golang : Convert long hexadecimal with strconv.ParseUint example
+10.6k Golang : How to delete element(data) from map ?
+16.1k Golang : Generate universally unique identifier(UUID) example
+6.8k Golang : Find the longest line of text example
+5.8k Javascript : How to replace HTML inside <div>?
+29.3k Golang : Save map/struct to JSON or XML file
+7.1k Golang : Get environment variable
+9.7k PHP : Get coordinates latitude/longitude from string
+10.5k Generate Random number with math/rand in Go
+37.5k Upload multiple files with Go
+10.2k Golang : How to get quoted string into another string?