Golang image.NRGBA and NRGBA64 types examples
package image
NRGBA is an in-memory image whose At method returns color.NRGBA values.
NRGBA64 is an in-memory image whose At method returns color.NRGBA64 values.
Golang image.NRGBA and NRGBA64 types usage examples
Example 1: (taken https://github.com/disintegration/imaging/blob/master/tools.go )
// Crop cuts out a rectangular region with the specified bounds
// from the image and returns the cropped image.
func Crop(img image.Image, rect image.Rectangle) *image.NRGBA {
src := toNRGBA(img)
srcRect := rect.Sub(img.Bounds().Min)
sub := src.SubImage(srcRect)
return Clone(sub) // New image Bounds().Min point will be (0, 0)
}
Example 2:
func getSubImage(src image.Image, rect image.Rectangle) image.Image {
if img, ok := src.(*image.NRGBA); ok {
return img.SubImage(rect)
}
if img, ok := src.(*image.NRGBA64); ok {
return img.SubImage(rect)
}
...
References :
https://github.com/disintegration/imaging/blob/master/tools.go
Advertisement
Something interesting
Tutorials
+10.1k Golang : Intercept and process UNIX signals example
+20.7k Golang : Convert seconds to minutes and remainder seconds
+11.5k Golang : Sort and reverse sort a slice of bytes
+17.4k Golang : Get path name to current directory or folder
+5.1k Facebook : How to force facebook to scrape latest URL link data?
+8.5k Facebook : Getting the friends list with PHP return JSON format
+28.3k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+8.4k Golang : Detect number of active displays and the display's resolution
+19.5k Golang : Underscore or snake_case to camel case example
+4.8k Javascript : How to refresh page with JQuery ?
+10.6k Get form post value in Go
+28.2k Golang : JQuery AJAX post data to server and send data back to client example