По мотивам статьи Скота Хансельмана написал небольшой snippet на VB.NET для вывода QR кода в литерал с использованием стандарта Data URL:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
Imports ZXing Imports ZXing.Common Imports System.IO Imports System.Drawing.Imaging ... Dim barcodeWriter = New BarcodeWriter() With { .Format = BarcodeFormat.QR_CODE, .Options = New EncodingOptions() With { .Height = 250, .Width = 250, .Margin = 5 } } barcodeWriter.Options.Hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8") barcodeWriter.Options.Hints.Add(EncodeHintType.DISABLE_ECI, True) Using bitmap = barcodeWriter.Write("whatever data you want to put in here") Using stream = New MemoryStream() bitmap.Save(stream, ImageFormat.Gif) Dim qr As String = String.Format("data:image/gif;base64,{0}", Convert.ToBase64String(stream.ToArray())) Literal1.Text = "<img src=""" & qr & """>" End Using End Using |
14.05.2014 – Добавлена возможность кодировать русский текст (и не только русский:)
Cсылки по теме: