package main import ( "image" "image/color" "image/draw" "image/png" "os" "github.com/boombuler/barcode" "github.com/boombuler/barcode/code128" "golang.org/x/image/font" "golang.org/x/image/font/basicfont" "golang.org/x/image/math/fixed" ) func subtitleBarcode(bc barcode.Barcode) image.Image { fontFace := basicfont.Face7x13 fontColor := color.RGBA{0, 0, 0, 255} margin := 5 // Space between barcode and text // Get the bounds of the string bounds, _ := font.BoundString(fontFace, bc.Content()) widthTxt := int((bounds.Max.X - bounds.Min.X) / 64) heightTxt := int((bounds.Max.Y - bounds.Min.Y) / 64) // calc width and height width := widthTxt if bc.Bounds().Dx() > width { width = bc.Bounds().Dx() } height := heightTxt + bc.Bounds().Dy() + margin // create result img img := ima
条码
最新推荐文章于 2024-08-13 08:11:34 发布