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
+21.9k Golang : Use TLS version 1.2 and enforce server security configuration over client
+8.8k Golang : On lambda, anonymous, inline functions and function literals
+22.7k Golang : Round float to precision example
+5.3k Golang : Generate Interleaved 2 inch by 5 inch barcode
+13.4k Golang : error parsing regexp: invalid or unsupported Perl syntax
+7.3k Golang : How to convert strange string to JSON with json.MarshalIndent
+39.2k Golang : How to read CSV file
+7.5k Golang : Rename part of filename
+20.2k Golang : How to get own program name during runtime ?
+20.2k Golang : Convert seconds to human readable time format example
+5.9k Facebook : How to force facebook to scrape latest URL link data?
+10.2k Golang : Text file editor (accept input from screen and save to file)