Created
July 11, 2016 07:57
-
-
Save sanmai/65650f199b7bd75f92968849929314e5 to your computer and use it in GitHub Desktop.
Adds label to an image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"image" | |
"image/color" | |
"image/png" | |
"os" | |
"golang.org/x/image/font" | |
"golang.org/x/image/font/basicfont" | |
"golang.org/x/image/math/fixed" | |
) | |
func main() { | |
img := image.NewRGBA(image.Rect(0, 0, 320, 240)) | |
x, y := 100, 100 | |
point := fixed.Point26_6{fixed.Int26_6(x * 64), fixed.Int26_6(y * 64)} | |
d := &font.Drawer{ | |
Dst: img, | |
Src: image.NewUniform(color.Black), | |
Face: basicfont.Face7x13, | |
Dot: point, | |
} | |
d.DrawString("Test 123") | |
png.Encode(os.Stdout, img) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Face7x13 is a fixed font, how to increase the font size?