当前位置: 首页> 游戏> 单机 > 南京平面设计师联盟_网站建设的策划_怎么做网站推广_免费做网站软件

南京平面设计师联盟_网站建设的策划_怎么做网站推广_免费做网站软件

时间:2025/7/13 17:38:15来源:https://blog.csdn.net/janthinasnail/article/details/144351920 浏览次数:0次
南京平面设计师联盟_网站建设的策划_怎么做网站推广_免费做网站软件

1、下载

# 创建目录
# 进入目录
# 执行 go mod init xxx 命令(即:在当前目录初始化创建一个模块)# 下载gozxing
go get github.com/makiuchi-d/gozxing

2、生成二维码

package mainimport ("image/png""os""github.com/makiuchi-d/gozxing""github.com/makiuchi-d/gozxing/oned""github.com/makiuchi-d/gozxing/qrcode"
)func main() {// writeBarcode()writeQrcode()
}// 条形码
func writeBarcode() {// Generate a barcode image (*BitMatrix)writer := oned.NewCode128Writer()img, _ := writer.Encode("content: bar code", gozxing.BarcodeFormat_CODE_128, 100, 50, nil)file, _ := os.Create("barcode.png")defer file.Close()png.Encode(file, img)
}// 二维码
func writeQrcode() {// Generate a qrcode image (*BitMatrix)writer := qrcode.NewQRCodeWriter()img, _ := writer.Encode("content: qr code", gozxing.BarcodeFormat_QR_CODE, 100, 100, nil)file, _ := os.Create("qrcode.png")defer file.Close()png.Encode(file, img)
}

3、识别二维码

package mainimport ("fmt""image"_ "image/png""os""github.com/makiuchi-d/gozxing""github.com/makiuchi-d/gozxing/oned""github.com/makiuchi-d/gozxing/qrcode"
)func main() {// readBarcode()readQrcode()
}// 条形码
func readBarcode() {// open and decode image filefile, _ := os.Open("barcode.png")img, _, _ := image.Decode(file)// prepare BinaryBitmapbmp, _ := gozxing.NewBinaryBitmapFromImage(img)// decode imagereader := oned.NewCode128Reader()result, _ := reader.Decode(bmp, nil)fmt.Println(result)
}// 二维码
func readQrcode() {// open and decode image filefile, _ := os.Open("qrcode.png")img, _, _ := image.Decode(file)// prepare BinaryBitmapbmp, _ := gozxing.NewBinaryBitmapFromImage(img)// decode imagereader := qrcode.NewQRCodeReader()result, _ := reader.Decode(bmp, nil)fmt.Println(result)
}

详见:

https://pkg.go.dev/search?q=qrcode

GitHub - makiuchi-d/gozxing: Port of ZXing (https://github.com/zxing/zxing) core to pure Go.

关键字:南京平面设计师联盟_网站建设的策划_怎么做网站推广_免费做网站软件

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: