Golang image.Paletted.SubImage function example
package image
func (p *Paletted) SubImage(r Rectangle) Image
SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.
Golang image.Paletted.SubImage function usage example
package main
import (
"image"
"image/color"
"fmt"
)
func main() {
p := color.Palette{color.NRGBA{0xf0, 0xf0, 0xf0, 0xff}}
rect := image.Rect(0, 0, 100, 100)
paletted := image.NewPaletted(rect, p)
subimg := paletted.SubImage(image.Rect(0, 0, 50, 50))
fmt.Println(subimg.Bounds())
}
Output :
(0,0)-(50,50)
Reference :
Advertisement
Something interesting
Tutorials
+11.5k CodeIgniter : Import Linkedin data
+17.5k Golang : Linked list example
+15.6k Chrome : ERR_INSECURE_RESPONSE and allow Chrome browser to load insecure content
+13.7k Golang : Activate web camera and broadcast out base64 encoded images
+7.8k Golang : Scan files for certain pattern and rename part of the files
+6.1k Golang : Debug with Godebug
+26.4k Golang : Convert(cast) string to uint8 type and back to string
+19.2k Golang : Delete item from slice based on index/key position
+16.9k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+11.5k Golang : Generate DSA private, public key and PEM files example
+17k Golang : Get input from keyboard
+9.9k Golang : Check if user agent is a robot or crawler example