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
+8.2k Golang : Get final or effective URL with Request.URL example
+17.2k Google Chrome : Your connection to website is encrypted with obsolete cryptography
+5.9k Golang : Generate multiplication table from an integer example
+18.6k Golang : Generate thumbnails from images
+46.4k Golang : Encode image to base64 example
+10.8k Android Studio : Checkbox for user to select options example
+8.1k Golang : Get all countries phone codes
+21.2k Golang : How to get time zone and load different time zone?
+22.8k Golang : untar or extract tar ball archive example
+31.5k Golang : bufio.NewReader.ReadLine to read file line by line
+7.3k Golang : How to iterate a slice without using for loop?
+6.9k Mac OSX : Find large files by size