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
+8.6k Golang : Another camera capture GUI application with GTK and OpenCV
+15.6k Golang : Validate hostname
+31.9k Golang : Convert an image file to []byte
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+9.4k Golang : Create unique title slugs example
+37.5k Golang : Converting a negative number to positive number
+10.9k Golang : Sieve of Eratosthenes algorithm
+17.7k Golang : [json: cannot unmarshal object into Go value of type]
+5.3k Swift : Convert string array to array example
+5.4k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+7.4k Golang : How to detect if a sentence ends with a punctuation?