Quantcast
Channel: ZXing.Net
Viewing all articles
Browse latest Browse all 1871

New Post: ZXing.QrCode in VB .net - troubles to start :(

$
0
0
Dear all,
I have a troubles to start with ZXing library usage
Please, if someone could check my piece of code...
Or if you can past some example in VB .NET ...
(basically I`m stopped on convert of Bitmap to Byte array , as it seems...
result of this is index out of range in zxing.dll

Thanks a lot

code:
Imports ZXing
Imports ZXing.QrCode


Public Class Form1
    Public Shared Function ConvertToByteArray(ByVal value As Bitmap) As Byte()
        Dim bitmapBytes As Byte()
        Using stream As New System.IO.MemoryStream
            value.Save(stream, value.RawFormat)
            bitmapBytes = stream.ToArray
        End Using
        Return bitmapBytes

    End Function



    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim readCode As New ZXing.QrCode.QRCodeReader()

        Dim imageFile As New Bitmap("C:\qr2.jpg")
        Dim Lumin As New RGBLuminanceSource(ConvertToByteArray(imageFile), imageFile.Width, imageFile.Height)
        Dim HBin As New ZXing.Common.HybridBinarizer(Lumin)
        Dim Bitm As New ZXing.BinaryBitmap(HBin)
        Dim result = readCode.decode(Bitm)

    End Sub
End Class

Viewing all articles
Browse latest Browse all 1871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>