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
+32.2k Golang : Convert []string to []byte examples
+12.5k Golang : Forwarding a local port to a remote server example
+6.3k Javascript : Generate random key with specific length
+8.2k Android Studio : Rating bar example
+8.1k Golang : Tell color name with OpenCV example
+13.8k Generate salted password with OpenSSL example
+46.2k Golang : Read tab delimited file with encoding/csv package
+34k Golang : Proper way to set function argument default value
+7.1k Nginx : How to block user agent ?
+24.1k Golang : Upload to S3 with official aws-sdk-go package
+14.4k Golang : How to filter a map's elements for faster lookup