基本信息
源码名称:VB.NET 二维码带logo
源码大小:2.51M
文件格式:.zip
开发语言:ASP
更新时间:2020-10-02
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍


Imports System.IO
Imports System.Drawing.Imaging
Imports Gma.QrCodeNet.Encoding.Windows.Render
Imports Gma.QrCodeNet.Encoding
Public Class TwoCodeHelper
	Private Shared Function Getcode(writeStr As String, size As Integer) As Image
		Dim qrEncoder As New QrEncoder(ErrorCorrectionLevel.H)
		Dim qrCode As New QrCode()
		qrEncoder.TryEncode(writeStr, qrCode)

		Dim renderer As New GraphicsRenderer(New FixedCodeSize(size, QuietZoneModules.Zero), Brushes.Black, Brushes.White)
		Dim ms As New MemoryStream()
		renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, ms)
		Dim image As Image = Bitmap.FromStream(ms)
		Return image
	End Function
	Private Shared Function Getlogo(path As String, Optional width As Integer = 30, Optional heght As Integer = 30) As Bitmap
		Dim newBmp As New Bitmap(path)
		Dim bmp As New Bitmap(newBmp, width, heght)
		Return bmp
	End Function
	Public Shared Function CreateCode(code As String, logoPath As String) As Image
		Dim size As Integer = 200
		Dim bCode As Image = Getcode(code, size)
		If Not String.IsNullOrEmpty(logoPath) Then
			Dim logoImg As Bitmap = Getlogo(logoPath)
			If logoImg IsNot Nothing Then
				Dim bLogo As Bitmap = TryCast(logoImg, Bitmap)
				bLogo = New Bitmap(bLogo, size / 3, size / 3)
				Dim Y As Integer = bCode.Height
				Dim X As Integer = bCode.Width
				Dim point As New Point(X / 2 - (size / 3) / 2, Y / 2 - (size / 3) / 2)
				Dim g As Graphics = Graphics.FromImage(bCode)
				g.DrawImage(bLogo, point)
			End If
		End If
		Return bCode
	End Function
End Class