Java QR Code Reader & Scanner

Scanning & Reading QR Code Barcodes in Java Class


  • Easy to integrate QR Code barcode reading and scanning feature in your Java applications
  • Complete developed in Java SDK 1.4.2. No registration key. No activation code.
  • Scanning QR Code barcodes from multiple image formats, like BMP, GIF, JPEG, PNG, TIFF formats
  • Reading barcode QR Code from multi-page TIFF documents
  • Reliable & Mature Java Barcode QR Code Reader & Scanner library from 2004


How to scan, read QR Code from image in Java application?

  1. Download Java QR Code Reader Library
  2. Install Java jar SDK to read QR Code from images in Java web and desktop applications.
  3. Step by Step Tutorial










 

Java Barcode QR Code Scanner Introduction

Top
Scanning and reading barcode QR Code from image file is a key feature in OnBarcode Java Barcode Scanner library SDK. Java Barcode Reader is completely developed in Java SDK 1.4.2, and you can easy integrate the barcode reading feature in your Java project without any registration key, activation code.
 

Install QR Code library to Java project

  • Add OnBarcode.BarcodeReader.jar to your Java project reference.
 

How to scan, read QR Codes image file in Java class?

Top
Pass your QR Code barcode image file, and barcode type to method BarcodeScanner.Scan(), and it will return all QR Code barcode data in the image file.

String[] datas = BarcodeScanner.Scan(
    "qrcode-sample-image.png", BarcodeType.QRCode); 



Note: Besides image file, you can also pass java.awt.image.RenderedImage object to the Scan method.


Running the method Scan, you will easily get all QR Code data from a single QR Code image file in Java application.





Scan and read all QR Code informations from an image file using Java

Top
Call method BarcodeScanner.ScanInDetails() with the same input parameters, you will get all scanned QR Codes with detailed information in BarcodeDetail objects, such as scanned QR Code region.

BarcodeDetail[] datasInDetail = BarcodeScanner.ScanInDetails(
    "qrcode-sample.png", BarcodeType.QRCode);

Here are some information about BarcodeDetail
  • Rotation: get the scanned QR Code rotation angle
  • X1, Y1, X2, Y2, X3, Y3, X4, Y4: 4 coordinate locations on the scanned image to cover the scanned QR Code symbol
  • IsGS1Compitable: If true, the scanned QR Code is a GS1 compatible QR Code. You need read the GS1 data message from it.
  • IsStructuredAppend: If true, the scanned QR Code symbol is part of the Structured Append QR Code symbols
  • GetDataBytes(): Get the QR Code data in byte array.
  • GetMessage(): Get the QR Code data in specified encoding format.

Extract QR Code Barcode Properties

Call method BarcodeDetail.GetBarcodeProps() to get the QRCodeProps object, where you can access all scanned QR Code information in the Java application.

Here are the list of QR Code properties, you can use the getter method to extract the information from the QRCodeProps object.
  • Version. QR Code version used in encoding.
  • DataMode. QR Code encoding data mode. If the QR Code is using more than one data modes, it will return QRCodeDataMode.Mix
  • ECL. QR Code error correction level.
  • IsStructuredAppend. Indicate whether QR Code is in structured append mode.
  • SymbolPosition. If the QR Code is in Structured Append mode, get it's symbol position. Start from 1.
  • SymbolCount. If the QR Code is in Structured Append mode, get number of symbols in the group.
  • Parity. If the QR Code is in Structured Append mode, get 8-bit parity data.
BarcodeDetail[] qrcodesInDetail = BarcodeScanner.ScanInDetails(
	    "sample-qrcode-image.png", BarcodeType.QRCode);

if (qrcodesInDetail != null && qrcodesInDetail.length > 0)
{
    for (BarcodeDetail qrcode : qrcodesInDetail)
    {
    	System.out.println("Message: " + qrcode.getMessage());
        if (qrcode.getType() == BarcodeType.QRCode)
        {
            QRCodeProps qrcodeProps = (QRCodeProps)b.GetBarcodeProps();
            //  Get version used in encoding.
            System.out.println("Version: "  + qrcodeProps.getVersion().toString());
            //  Get data mode used in encoding.
            //  QRCodeDataMode.Mix for more than 1 data modes used.
            System.out.println("Data Mode: " + qrcodeProps.getDataMode().toString());
            //  Get error correction level used in encoding.
            System.out.println("ECL: " + qrcodeProps.getECL().toString());
            //  Indicate if it contains structure append block.
            System.out.println("Is Structure Append: " + qrcodeProps.isStructuredAppend());
            if (qrcodeProps.isStructuredAppend())
            {
                //  Get symbol position. Start from 1.
            	System.out.println("Symbol Position: " + qrcodeProps.getSymbolPosition());
                //  Get number of symbols in the group.
            	System.out.println("Symbol Count: " + qrcodeProps.getSymbolCount());
                //  Get 8-bit parity data.
            	System.out.println("Parity: " + qrcodeProps.getParity());
            }
        }
    }
}




Scan and read all QR Code informations from an image file using Java

Top
QR Code supports encoding lots of character sets and some industry standard data formats. To help process these complex text message, barcode reader library includes multiple utility methods to handle them.

Here you will learn how to process the following character sets or text message from scanned QR Code in Java

  • ASCII text. Including printing and non-printing characters.
  • Unicode text
  • Binary data
  • GS1 data elements


Read ASCII characters from QR Code in Java

ASCII text include 128 characters. The first 32 characters and the last character are non-printing ones, such as character 'carriage return'.

The Java sample source code below explains how to scan QR Code and parse the ASCII characters from QRCode in Java application.

  • In the scanned and returned BarcodeDetail object, use method getASCIITextMessage to extract the ASCII characters in Java code.

BarcodeDetail[] datas = BarcodeScanner.ScanInDetails(
		"qrcode-ascii-sample.png", BarcodeType.QRCode);
	            
for (int j = 0; j < datas.length; j++) {
	String barcodeAsciiText = datas[j].getASCIITextMessage();
}




Read Unicode text from QR Code in Java



QR Code supports Unicode text encoding. To decode QR Code with Unicode text properly, you need use the same encoding as the QR Code generator or encoder software or printer. The most common encoding is using UTF-8 encoding.

The Java source code below explains how to read QR Code and decode Unicode text using UTF-8 encoding in Java program.

BarcodeDetail[] datas = BarcodeScanner.ScanInDetails(
	    "qrcode-unicode-sample.png", BarcodeType.QRCode);
	            
for (int j = 0; j < datas.length; j++) {
	String textMsgDecoded = new String(datas[j].getDataBytes(), "UTF-8");
	System.out.println("Unicode text: " + textMsgDecoded);
}





Scan, read GS1 QR Code in Java



The GS1 System uses QR Code as one of its data carrier. The GS1 data message encoded in QR Code usually includes a list of AI (Application Identifier) Code and AI data pair, and some control characters, such as Function 1 Symbol Character (FNC1).

OnBarcode Java Barcode Reader library will help you easily scan GS1 QR Code and parse GS1 text message without processing any GS1 control characters.

BarcodeDetail[] result = BarcodeScanner.ScanInDetails(
		"qrcode-gs1-data.png", BarcodeType.QRCode);

for (BarcodeDetail b : result) {
    //  Indicate if the QR Code is conform to GS1 system.
    if (b.isGS1Compitable()) {
        //  Get message in string format.
        //  Eg. "(415)5412345678908(3911)710125"
        String msg = b.getMessage();
        System.out.println("Raw Data: " + b.getData());
        System.out.println("Text Message: " + msg);
        //  Retrieve each AI and its data from the message.
        //  Eg.
        //  AI:   415
        //  Data: 5412345678908
        //  AI:   3911
        //  Data: 710125
        String[] vals = msg.split("[()]");

        for (int i = 0; i < vals.length; i += 2) {
        	System.out.println("AI: " + vals[i]);
        	System.out.println("Data: " + vals[i + 1]);
         }
    }
}

Scan and read styled QR Code with logo image printed in Java

Top
OnBarcode Java QR Code Reader library supports automatically scanning and reading colored QR Code with logo image printed in Java program.













Common Asked Questions

How to read QR Code on desktop?

You can use barcode scanner software installed on computer or barcode scanner device to read and extract QR Code from photo or image files. OnBarcode Java QR Code Reader library helps Java developers to build desktop application (Windows, Linux, macOS) with QR Code scanning and reading functions with few lines of Java source codes.

How to read a QR code that's on your screen?

To read a QR Code on your computer screen, try the following steps
  • Take and save the screenshot of the QR Code image on the computer
  • Use QR Code scanner desktop software to read the QR Code from the photo or image file
Java QRCode Scanner and Reader library supports Java professionals quickly to build a desktop (Windows, Linux, or macOS) application with QR Code decoder features integrated.

How do I scan a QR code with my smart phone?

You can download and install QR Code Scanner app on the iPhone or Android phones. OnBarcode Java QR Code Scanner library supports building application for Adroid with QR Code reading functions.

How do you scan a QR code from an image?

Online QR Code decoder, QR Code Scanner software allow you to scan and extract a QR Code from an images. Using OnBarcode QR Code Reader Java library, you can quickly build online QR Code scanner based on Java JSP, Servlet, Spring framework using Java api.

Is there a scanner or reader for QR codes?

You can use iPhone and Android phone build-in QR Code Scanner app to read the QR Codes. If you are a Java developer, you can easily build app for Android with QR Code Reader embed using Java Barcode Reader library.




































Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.