Golang image.NewAlpha16 function example

package image

 func NewAlpha16(r Rectangle) *Alpha16
  

NewAlpha16 returns a new Alpha16 with the given bounds.

Golang image.NewAlpha16 function usage example

 package main

 import (
 "fmt"
 "image"
 "image/png"
 "os"
 )

 func init() {
 image.RegisterFormat("png", "png", png.Decode, png.DecodeConfig)
 }

 func main() {
 imgfile, err := os.Open("./img.png")

 if err != nil {
 fmt.Println("img.png file not found!")
 os.Exit(1)
 }

 defer imgfile.Close()

 img, _, err := image.Decode(imgfile)

 fmt.Println(img.At(10, 10))

 bounds := img.Bounds()

 fmt.Println(bounds)

 canvas := image.NewAlpha16(bounds) // <-- here

 // is this image opaque
 op := canvas.Opaque()

 fmt.Println(op)
 }

Reference :

http://golang.org/pkg/image/#NewAlpha16

Advertisement