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
+28.2k Golang : Connect to database (MySQL/MariaDB) server
+11.2k CodeIgniter : How to check if a session exist in PHP?
+9.6k Javascript : Read/parse JSON data from HTTP response
+12k Golang : Convert a rune to unicode style string \u
+30.9k Golang : Interpolating or substituting variables in string examples
+22.2k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+21.8k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+17.6k Golang : Parse date string and convert to dd-mm-yyyy format
+14.9k Golang : How to check for empty array string or string?
+9.4k Android Studio : Indicate progression with ProgressBar example
+6.3k WARNING: UNPROTECTED PRIVATE KEY FILE! error message
+12.6k Golang : flag provided but not defined error