8 Star 19 Fork 1

ShirDon-廖显东/goGd

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
sample.go 1.39 KB
Copy Edit Raw Blame History
githubvip authored 2019-12-06 18:12 +08:00 . commit
package main
import gd "gitee.com/shirdonl/goGd"
import "fmt"
func main() {
// http://www.php.net/manual/en/function.imagecreatefromjpeg.php
pict := gd.CreateFromJpeg("source.jpg")
// http://www.php.net/manual/en/function.imagedestroy.php
defer pict.Destroy()
pict.Sharpen(10)
pict.Brightness(50)
// http://www.php.net/manual/en/function.imagecolorallocate.php
black := pict.ColorAllocate(0, 0, 0)
white := pict.ColorAllocate(255, 255, 255)
// http://php.net/manual/en/function.imagefilledpolygon.php
pict.FilledPolygon([]gd.Point{{200, 200}, {210, 210}, {212, 250}}, black)
pict.SmoothFilledEllipse(20, 20, 32, 32, white)
// http://www.php.net/manual/en/function.imagefilledellipse.php
pict.FilledEllipse(100, 100, 40, 50, white)
// http://www.php.net/manual/en/function.imagecopyresampled.php
pict.CopyResampled(pict, 40, 40, pict.Sx()-41, pict.Sy()-41, 20, 20, 40, 40)
// Non-Unicode font
font := gd.GetFont(gd.FONTGIANT)
// http://www.php.net/manual/en/function.imagechar.php
pict.Char(font, 100, 100, "B", black)
// http://www.php.net/manual/en/function.imagestring.php
pict.String(font, 100, 120, "bolknote.ru", black)
// Unicode font
fonts := gd.GetFonts()
fmt.Printf("Found %d X11 TTF font(s)\n", len(fonts))
if l := len(fonts); l > 0 {
pict.StringFT(black, fonts[l-1], 12, 0, 100, 150, "Hello! Привет!")
}
// http://www.php.net/Imagejpeg
pict.Jpeg("out.jpg", 95)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/shirdonl/goGd.git
git@gitee.com:shirdonl/goGd.git
shirdonl
goGd
goGd
4cf806c48fd0

Search