Golang image.Paletted.ColorModel, Opaque and PixOffset functions example
package image
Golang image.Paletted.ColorModel, Opaque and PixOffset functions 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("ColorModel : ",paletted.ColorModel())
fmt.Println("Opaque : ", paletted.Opaque())
fmt.Println("PixOffset : ", paletted.PixOffset(10,10))
}
Output :
ColorModel : [{240 240 240 255}]
Opaque : true
PixOffset : 1010
References :
http://golang.org/pkg/image/#Paletted.ColorModel
Advertisement
Something interesting
Tutorials
+33.8k Golang : convert(cast) bytes to string
+21.2k Golang : Clean up null characters from input data
+12.1k Golang : Perform sanity checks on filename example
+21.2k Golang : How to force compile or remove object files first before rebuild?
+12.9k Python : Convert IPv6 address to decimal and back to IPv6
+15.2k Golang : How to add color to string?
+24.6k Golang : How to validate URL the right way
+10.1k Golang : How to tokenize source code with text/scanner package?
+13k Swift : Convert (cast) Int to String ?
+14.8k Golang : Normalize unicode strings for comparison purpose
+6k PHP : How to check if an array is empty ?
+7.2k CloudFlare : Another way to get visitor's real IP address