Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7990863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:07:47+00:00 2026-06-04T13:07:47+00:00

I’m using the zxing C# port to decode a QR barcode. The code is

  • 0

I’m using the zxing C# port to decode a QR barcode.
The code is simple and based on an example I found online (see below).
The problem is, it always throws an “Index was outside the bounds of the array” exception.
My code sample happen to be in VB.NET, but the zxing library is implemented in C#

Dim re As qrcode.QRCodeReader
re = New qrcode.QRCodeReader()

Dim Img As New Bitmap("<image file path here>")

Dim res As com.google.zxing.Result

Dim bufimg As com.google.zxing.client.j2se.BufferedImageMonochromeBitmapSource
bufimg = New client.j2se.BufferedImageMonochromeBitmapSource(Img, False)
res = re.decode(bufimg)

Dim ret As String = res.getText()

I have seen multiple people complaining about the same issue in different forums, but haven’t found any suggested solution.

UPDATE If anyone knows of a different good QR reader that can easily integrate with a .NET application, please recommend

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:07:48+00:00Added an answer on June 4, 2026 at 1:07 pm

    Dont know if this gonna help u, but i paste my code if u want to use:

    Imports Zxing = com.google.zxing
    Imports System.Drawing
    
    Public Class Decodificador
        'Para leer todo tipo de codigos soportados por el proyecto zxing
        Private Reader As New Zxing.MultiFormatReader
        'Private Reader As New Zxing.qrcode.QRCodeReader
        Private Result As Zxing.Result
        Private Imagen As Bitmap
        Private Bitm As Zxing.BinaryBitmap
        Private HBin As Zxing.common.HybridBinarizer
        Private Lumin As RGBLuminanceSource
        'El orden para poder funcionar es: 
        'DetectarCodigoEnImagen (Obligatorio) >> PintarLocalizacion [opcional] >> DecodificarImagen (Obligatorio para sacar info).
        ''' <summary>
        ''' Devuelve True si ha localizado un QRCODE
        ''' </summary>
        ''' <param name="img"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function DetectarCodigoEnImagen(ByRef img As Image) As Boolean
            Try
                Imagen = New Bitmap(img)
                'Creamos un Mapa binario con la imagen y su tamaño
                Lumin = New RGBLuminanceSource(Imagen, Imagen.Width, Imagen.Height)
                HBin = New Zxing.common.HybridBinarizer(Lumin)
                Bitm = New Zxing.BinaryBitmap(HBin)
                'Decodificamos el mapa binario y guardamos todos los datos en Result
                Result = Reader.decode(Bitm)
                'Si ha encontrado un QRCode provocará una excepción y devolverá False
                'Si hay un QRCode, devolverá True
                Return True
            Catch ex As Exception
                Return False
            End Try
        End Function
        ''' <summary>
        ''' Dibuja cuadros rojos y amarillos en la localización del Codigo QR, ralentiza mucho el sistema.
        ''' Debe haberse detectado un codigo en la imagen para poder pintar.
        ''' Devuelve la imagen con el Codigo QR y la localización pintada
        ''' </summary>
        ''' <param name="img"></param>
        ''' <remarks></remarks>
        Public Function PintarLocalizacionQrCode(ByRef img As Image) As Image
            Try
                'Archivamos en una matriz todos los puntos de localización del QRcode
                Dim Puntos() As Zxing.ResultPoint = Result.ResultPoints
                'Creamos Graficos desde la imagen y poder pintar posteriormente
                Dim gr As Graphics = Graphics.FromImage(Imagen)
                'Dim gr As Graphics = Graphics.FromImage(Imagen)
                'Declaramos el tamaño del pincel para pintar y pintar2
                Dim TamPincel As Integer = 4
                Dim Pintar As New Pen(Color.Yellow, TamPincel)
                Dim Pintar2 As New Pen(Color.Red, TamPincel)
                'Declaramos una variable del mismo tipo que el arreglo Puntos() para poder navera por ella
                Dim PuntoAuxiliar As com.google.zxing.ResultPoint
    
                'Por cada punto en puntos() dibujamos 2 rectangulos en los indicadores de posición del QRCode
                For Each PuntoAuxiliar In Puntos
                    gr.DrawRectangle(Pintar, New Rectangle(PuntoAuxiliar.X - 10, PuntoAuxiliar.Y - 10, 20, 20))
                    gr.DrawRectangle(Pintar2, New Rectangle(PuntoAuxiliar.X - 13, PuntoAuxiliar.Y - 13, 26, 26))
                Next
                'Liberamos la memoria
                gr.Dispose()
                Return Imagen
            Catch ex As Exception
                Throw ex
            End Try
        End Function
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm making a simple page using Google Maps API 3. My first. One marker
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.