Golang image.Alpha16.Bounds function example
package image
func (p *Alpha16) Bounds() Rectangle
Golang image.Alpha16.Bounds 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)
bounds := img.Bounds()
alpha16 := image.NewAlpha16(bounds)
rect := alpha16.Bounds() // <-- here
fmt.Println("Min X : Y = ", rect.Min.X, rect.Min.Y)
fmt.Println("Max X : Y = ", rect.Max.X, rect.Max.Y)
}
Sample output ( depending on image file ) :
Min X : Y = 0 0
Max X : Y = 600 849
Reference :
Advertisement
Something interesting
Tutorials
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+8.1k Golang : Tell color name with OpenCV example
+14k Golang: Pad right or print ending(suffix) zero or spaces in fmt.Printf example
+26.3k Golang : Calculate future date with time.Add() function
+8.3k Golang : Auto-generate reply email with text/template package
+14k Golang : Compress and decompress file with compress/flate example
+5.4k Golang *File points to a file or directory ?
+8k Golang : Sort words with first uppercase letter
+13.1k Golang : Convert(cast) uintptr to string example
+16k Golang : Generate universally unique identifier(UUID) example
+14.5k Golang : How to determine if user agent is a mobile device example
+17.9k Golang : Qt image viewer example