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
+6.5k Golang : Calculate diameter, circumference, area, sphere surface and volume
+5.2k Responsive Google Adsense
+15.2k JavaScript/JQuery : Detect or intercept enter key pressed example
+18.5k Golang : Aligning strings to right, left and center with fill example
+46.5k Golang : Marshal and unmarshal json.RawMessage struct example
+14.4k Golang : On enumeration
+8k Golang : What fmt.Println() can do and println() cannot do
+7.8k Golang : Load DSA public key from file example
+4.8k Golang : A program that contain another program and executes it during run-time
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+8.2k Golang : Reverse text lines or flip line order example
+23.6k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date