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
+12.5k Golang : "https://" not allowed in import path
+12.6k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+6.9k Golang : How to solve "too many .rsrc sections" error?
+19.1k Golang : When to use public and private identifier(variable) and how to make the identifier public or private?
+13.4k Golang : Verify token from Google Authenticator App
+9.1k Golang : Simple histogram example
+19.9k Golang : Accept input from user with fmt.Scanf skipped white spaces and how to fix it
+9.9k Golang : Check if user agent is a robot or crawler example
+16.3k Golang : How to extract links from web page ?
+5.7k Golang : Frobnicate or tweaking a string example
+16.3k Golang :Trim white spaces from a string
+26.8k Golang : Find files by extension