Here is my code for reading a qr-code in a picturebox
no matter what code i try i always get a problem
BC30311 Unable to convert a value of type 'Bitmap' to 'Bitmap'.
' Obtenir l'image QR code à partir du fichier
Dim image As Bitmap = CType(Bitmap.FromFile("file.png"), Bitmap)
' Lire le contenu du fichier en tant qu'un tableau de bytes
Dim bytes As Byte() = File.ReadAllBytes("file.png")
Try
Using image
' Créer une source de luminance à partir de l'image
Dim source As LuminanceSource = New BitmapLuminanceSource(**image**)
' Créer un objet BinaryBitmap à partir de la source de luminance
Dim bitmap As BinaryBitmap = New BinaryBitmap(New HybridBinarizer(source))
' Décoder le QR code en utilisant un lecteur multi-formats
Dim result As Result = New MultiFormatReader().decode(bitmap)
If result IsNot Nothing Then
' Code trouvé
Dim data As String() = result.Text.Split(Environment.NewLine)
Else
' Pas de code trouvé
End If
End Using
Catch ex As Exception
Throw New Exception("Impossible de décoder le QR code : " & ex.Message)
End Try
Pls help !
I tried to read a qr-code with zxing.net in vb.net
but i always get a proble with luminanceSource and bitmap conversion
Try the following:
Create a
Windows Forms App (.NET Framework)Download/install NuGet package:
ZXing.NetAdd the following Imports:
Imports System.IOImports ZXingImports ZXing.CommonImports ZXing.QrCodeForm1.vb
Usage (decode QR code):
Note: The following assumes that a Button named
btnDecodeQrCodeexists on the Form.Usage (save QR Code):
Note: The following assumes that a Button named
btnSaveQrCodeexists on the Form.Resources