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.3k Golang : Calculate how many weeks left to go in a given year
+12.3k Golang : How to display image file or expose CSS, JS files from localhost?
+16.9k Golang : Read integer from file into array
+8.8k Golang : On lambda, anonymous, inline functions and function literals
+15.4k Golang : Find location by IP address and display with Google Map
+17.7k Golang : [json: cannot unmarshal object into Go value of type]
+9.4k Golang : Web(Javascript) to server-side websocket example
+10.6k Fix ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
+9.9k Golang : Turn string or text file into slice example
+17.7k How to enable MariaDB/MySQL logs ?
+46.4k Golang : Encode image to base64 example