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.8k Golang : convert(cast) float to string
+11.1k Golang : Read until certain character to break for loop
+10k Golang : Read file and convert content to string
+17.4k Golang : Get future or past hours, minutes or seconds
+12.1k Golang : Save webcamera frames to video file
+6k Golang : Compound interest over time example
+6.8k Default cipher that OpenSSL used to encrypt a PEM file
+4.9k Unix/Linux : secure copying between servers with SCP command examples
+7.7k Golang : Error reading timestamp with GORM or SQL driver
+12.4k Golang : Extract part of string with regular expression
+43.2k Golang : Convert []byte to image
+6.9k Golang : Fibonacci number generator examples