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
+15.2k Golang : Accurate and reliable decimal calculations
+11.6k Golang : Convert(cast) float to int
+7.7k Golang : Test if an input is an Armstrong number example
+13.1k Golang : Handle or parse date string with Z suffix(RFC3339) example
+17.2k Golang : When to use init() function?
+11.6k Golang : Display a text file line by line with line number example
+12.8k Swift : Convert (cast) Int or int32 value to CGFloat
+5.6k Golang : Detect words using using consecutive letters in a given string
+10.2k Golang : Check a web page existence with HEAD request example
+7.1k Golang : Squaring elements in array
+17.6k Golang : Parse date string and convert to dd-mm-yyyy format
+15.8k Golang : Get digits from integer before and after given position example