Golang image.Gray and Gray16 types examples
package image
Gray is an in-memory image whose At method returns color.Gray values.
Golang image.Gray and Gray16 types usage examples
Example 1:
func NewSurfaceFromImage(img image.Image) *Surface {
var format Format
switch img.(type) {
case *image.Alpha, *image.Alpha16:
format = FORMAT_A8
case *extimage.BGRN, *image.Gray, *image.Gray16, *image.YCbCr:
format = FORMAT_RGB24
default:
format = FORMAT_ARGB32
}
surface := NewSurface(format, img.Bounds().Dx(), img.Bounds().Dy())
surface.SetImage(img)
return surface
}
Example 2:
if img, ok := src.(*image.Gray); ok {
return img.SubImage(rect)
}
References :
https://github.com/ungerik/go-cairo/blob/master/surface.go
Advertisement
Something interesting
Tutorials
+7.9k Swift : Convert (cast) String to Float
+12.3k Golang : How to check if a string starts or ends with certain characters or words?
+12.5k Golang : HTTP response JSON encoded data
+62.7k Golang : Convert HTTP Response body to string
+5.9k Unix/Linux : How to open tar.gz file ?
+15k Golang : How do I get the local IP (non-loopback) address ?
+10.4k Golang : Meaning of omitempty in struct's field tag
+7.5k Golang : Handling Yes No Quit query input
+5.8k Linux : Disable and enable IPv4 forwarding
+16.5k Golang : Check if a string contains multiple sub-strings in []string?
+9.4k Golang : Apply Histogram Equalization to color images
+37.5k Golang : Converting a negative number to positive number