com.aspose.barcode.barcoderecognition

Class BarCodeReader

  • java.lang.Object
    • com.aspose.barcode.barcoderecognition.BarCodeReader


  • public class BarCodeReader
    extends java.lang.Object

    BarCodeReader encapsulates an image which may contain one or several barcodes, it then can perform ReadBarCodes operation to detect barcodes.


     This sample shows how to detect Code39 and Code128 barcodes.
     
     BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
     for(BarCodeResult result : reader.readBarCodes())
     {
        System.out.println("BarCode Type: " + result.getCodeTypeName());
        System.out.println("BarCode CodeText: " + result.getCodeText());
     }
     
    • Constructor Detail

      • BarCodeReader

        public BarCodeReader()

        Initializes a new instance of the BarCodeReader class with default values. Requires to set image (SetBitmapImage()) before to call ReadBarCodes() method.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BarCodeReader reader = new BarCodeReader();
         reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         reader.setBarCodeImage("c:\\test.png");
         for(BarCodeResult result : reader.readBarCodes())
         {
             System.out.println("BarCode Type: " + result.getCodeTypeName());
             System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
      • BarCodeReader

        public BarCodeReader(java.awt.image.BufferedImage image)

        Initializes a new instance of the BarCodeReader class from an image.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BufferedImage bmp = ImageIO.read(new File("c:\\test.png"));
         BarCodeReader reader = new BarCodeReader(bmp);
         reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
         {
             System.out.println("BarCode Type: " + result.getCodeTypeName());
             System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        image - A Bitmap instance containing the image
      • BarCodeReader

        public BarCodeReader(java.awt.image.BufferedImage image,
                             BaseDecodeType decodeType)

        Initializes a new instance of the BarCodeReader class.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BufferedImage bmp = ImageIO.read(new File("c:\\test.png"));
         BarCodeReader reader = new BarCodeReader(bmp, new MultyDecodeType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
         {
             System.out.println("BarCode Type: " + result.getCodeTypeName());
             System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        image - The image.
        decodeType - The decode type1. It can be single or multy
      • BarCodeReader

        public BarCodeReader(java.awt.image.BufferedImage image,
                             BaseDecodeType... decodeTypes)

        Initializes a new instance of the BarCodeReader class.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BufferedImage bmp = ImageIO.read(new File("c:\\test.png"));
         BarCodeReader reader = new BarCodeReader(bmp, DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode Type: " + result.getCodeTypeName());
            System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        image - The image.
        decodeTypes - Decode types.
      • BarCodeReader

        public BarCodeReader(java.awt.image.BufferedImage image,
                             java.awt.Rectangle area,
                             BaseDecodeType... decodeTypes)

        Initializes a new instance of the BarCodeReader class.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BufferedImage bmp = ImageIO.read(new File("c:\\test.png"));
         BarCodeReader reader = new BarCodeReader(bmp, new Rectangle(0, 0, bmp.getWidth(), bmp.getHeight()), DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
         {
             System.out.println("BarCode Type: " + result.getCodeTypeName());
             System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        image - The image.
        area - The area for recognition.
        decodeTypes - Decode types.
      • BarCodeReader

        public BarCodeReader(java.awt.image.BufferedImage image,
                             java.awt.Rectangle[] areas,
                             BaseDecodeType type)

        Initializes a new instance of the BarCodeReader class.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BufferedImage bmp = ImageIO.read(new File("c:\\test.png"));
         BarCodeReader reader = new BarCodeReader(bmp, new Rectangle(0, 0, bmp.getWidth(), bmp.getHeight()), new MultyDecodeType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode Type: " + result.getCodeTypeName());
            System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        image - The image.
        areas - The area for recognition.
        type - The decode type.
      • BarCodeReader

        public BarCodeReader(java.lang.String filename)

        Initializes a new instance of the BarCodeReader class from file.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BarCodeReader reader = new BarCodeReader("c:\\test.png");
         reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
         {
             System.out.println("BarCode Type: " + result.getCodeTypeName());
             System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        filename - The filename.
      • BarCodeReader

        public BarCodeReader(java.lang.String filename,
                             BaseDecodeType type)

        Initializes a new instance of the BarCodeReader class.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BarCodeReader reader = new BarCodeReader("c:\\test.png", new MultyDecodeType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
         {
             System.out.println("BarCode Type: " + result.getCodeTypeName());
             System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        filename - The filename.
        type - The decode type.
      • BarCodeReader

        public BarCodeReader(java.lang.String filename,
                             BaseDecodeType... decodeTypes)

        Initializes a new instance of the BarCodeReader class.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode Type: " + result.getCodeTypeName());
            System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        filename - The filename.
        decodeTypes - Decode types.
      • BarCodeReader

        public BarCodeReader(java.io.InputStream stream)

        Initializes a new instance of the BarCodeReader class.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         InputStream fstr = new FileInputStream(new File("c:\\test.png"));
         BarCodeReader reader = new BarCodeReader(fstr);
         reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
         {
             System.out.println("BarCode Type: " + result.getCodeTypeName());
             System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        stream - The stream.
      • BarCodeReader

        public BarCodeReader(java.io.InputStream stream,
                             BaseDecodeType type)

        Initializes a new instance of the BarCodeReader class.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         InputStream fstr = new FileInputStream("c:\\test.png");
         BarCodeReader reader = new BarCodeReader(fstr, new MultyDecodeType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
         {
             System.out.println("BarCode Type: " + result.getCodeTypeName());
             System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        stream - The stream.
        type - The decode type.
      • BarCodeReader

        public BarCodeReader(java.io.InputStream stream,
                             BaseDecodeType... decodeTypes)

        Initializes a new instance of the BarCodeReader class.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         InputStream fstr = new FileInputStream("c:\\test.png"));
         BarCodeReader reader = new BarCodeReader(fstr, DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode Type: " + result.getCodeTypeName());
            System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        stream - The stream.
        decodeTypes - Decode types.
    • Method Detail

      • getProcessorSettings

        public static ProcessorSettings getProcessorSettings()

        Gets a settings of using processor cores.


         This sample shows how to use ProcessorSettings to add maximum multi-threaded performnce
         
         //this allows to use all cores for single BarCodeReader call
         BarCodeReader.getProcessorSettings().setUseAllCores(true);
         //this allows to use current count of cores
         BarCodeReader.getProcessorSettings().setUseAllCores(false);
         BarCodeReader.getProcessorSettings().setUseOnlyThisCoresCount(Math.max(1, Environment.getProcessorCount() / 2));
         
      • getTimeout

        public int getTimeout()

        Gets the timeout of recognition process in milliseconds.

         BarCodeReader reader = new BarCodeReader("c:\\test.png");
             reader.setTimeout(5000);
             for(BarCodeResult result : reader.readBarCodes())
                 System.out.println("BarCode CodeText: " + result.getCodeText());
         
        Returns:
        The timeout.
      • setTimeout

        public void setTimeout(int value)

        Sets the timeout of recognition process in milliseconds.

         BarCodeReader reader = new BarCodeReader("c:\\test.png");
         reader.setTimeout(5000);
         for(BarCodeResult result : reader.readBarCodes())
            System.out.println("BarCode CodeText: " + result.getCodeText());
         
        Parameters:
        value - The timeout.
      • getChecksumValidation

        public ChecksumValidation getChecksumValidation()

        Enable checksum validation during recognition for 1D barcodes.

        Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible.

        Checksum never used: Codabar

        Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN

        Checksum always used: Rest symbologies


         This sample shows influence of ChecksumValidation on recognition quality and results
         
         BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.EAN_13, "1234567890128");
         generator.save("c:\\test.png");
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.EAN_13);
         //checksum disabled
         reader.setChecksumValidation(ChecksumValidation.OFF);
         for(BarCodeResult result : reader.readBarCodes())
         {
             System.out.println("BarCode CodeText: " + result.getCodeText());
             System.out.println("BarCode Value: " + result.getExtended().getOneD().getValue());
             System.out.println("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum());
          }
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.EAN_13);
         //checksum enabled
         reader.setChecksumValidation(ChecksumValidation.ON);
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode CodeText: " + result.getCodeText());
            System.out.println("BarCode Value: " + result.getExtended().getOneD().getValue());
            System.out.println("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum());
         }
         
        Value: The checksum validation flag.
      • setChecksumValidation

        public void setChecksumValidation(ChecksumValidation value)

        Enable checksum validation during recognition for 1D barcodes.

        Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible.

        Checksum never used: Codabar

        Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN

        Checksum always used: Rest symbologies


         This sample shows influence of ChecksumValidation on recognition quality and results
         
         BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.EAN_13, "1234567890128");
         generator.save("c:\\test.png");
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.EAN_13);
         //checksum disabled
         reader.setChecksumValidation(ChecksumValidation.OFF);
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode CodeText: " + result.getCodeText());
            System.out.println("BarCode Value: " + result.getExtended().getOneD().getValue());
            System.out.println("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum());
         }
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.EAN_13);
         {
             //checksum enabled
             reader.setChecksumValidation(ChecksumValidation.ON);
             for(BarCodeResult result : reader.readBarCodes())
             {
                 System.out.println("BarCode CodeText: " + result.getCodeText());
                 System.out.println("BarCode Value: " + result.getExtended().getOneD().getValue());
                 System.out.println("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum());
             }
         }
         
        Value: The checksum validation flag.
      • setChecksumValidation

        @Deprecated
        public void setChecksumValidation(int value)
        Deprecated. 
        Enable checksum validation during recognition for 1D barcodes. Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. Checksum never used: Codabar Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN Checksum always used: Rest symbologies
        Parameters:
        value - The checksum validation flag.
      • getStripFNC

        public boolean getStripFNC()

        Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false.


         This sample shows how to strip FNC characters
         
         BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.GS1Code128, "(02)04006664241007(37)1(400)7019590754"))
         generator.save("c:\\test.png");
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_128);
         //StripFNC disabled
         reader.setStripFNC(false);
         for(BarCodeResult result : reader.readBarCodes())
         {
             System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_128);
         //StripFNC enabled
         reader.setStripFNC(true);
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
      • setStripFNC

        public void setStripFNC(boolean value)

        Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false.


         This sample shows how to strip FNC characters
         
         BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.GS1Code128, "(02)04006664241007(37)1(400)7019590754");
         generator.save("c:\\test.png");
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_128);
         //StripFNC disabled
         reader.setStripFNC(false);
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_128);
         //StripFNC enabled
         reader.setStripFNC(true);
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
      • getCustomerInformationInterpretingType

        public CustomerInformationInterpretingType getCustomerInformationInterpretingType()

        Gets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER.

      • setCustomerInformationInterpretingType

        public void setCustomerInformationInterpretingType(CustomerInformationInterpretingType value)

        Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER.

      • setCustomerInformationInterpretingType

        public void setCustomerInformationInterpretingType(int value)

        Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER.

      • abort

        public void abort()

        Function requests termination of current recognition session from other thread. Abort is unblockable method and returns control just after calling. The method should be used when recognition process is too long.


         This sample shows how to call Abort function from other thread
         
          final BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
          Thread thread1 = new Thread(new Runnable()
          {
      • getFoundBarCodes

        public BarCodeResult[] getFoundBarCodes()

        Gets recognized BarCodeResults array


         This sample shows how to read barcodes with BarCodeReader
         
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         {
             reader.readBarCodes();
             for(int i = 0; reader.getFoundCount() > i; ++i)
                 System.out.println("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText());
         }
         
        Value: The recognized BarCodeResults array
      • getFoundCount

        public int getFoundCount()

        Gets recognized barcodes count


         This sample shows how to read barcodes with BarCodeReader
         
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         reader.readBarCodes();
         for(int i = 0; reader.getFoundCount() > i; ++i)
            System.out.println("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText());
         
        Value: The recognized barcodes count
      • readBarCodes

        public BarCodeResult[] readBarCodes()

        Reads BarCodeResults from the image.


         This sample shows how to read barcodes with BarCodeReader
         
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         for(BarCodeResult result : reader.readBarCodes())
            System.out.println("BarCode CodeText: " + result.getCodeText());
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         reader.readBarCodes();
         for(int i = 0; reader.getFoundCount() > i; ++i)
            System.out.println("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText());
         
        Returns:
        Returns array of recognized BarCodeResults on the image. If nothing is recognized, zero array is returned.
      • getQualitySettings

        public final QualitySettings getQualitySettings()

        QualitySettings allows to configure recognition quality and speed manually. You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, HighQuality, MaxBarCodes or you can manually configure separate options. Default value of QualitySettings is NormalQuality.


         This sample shows how to use QualitySettings with BarCodeReader
         
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         //set high performance mode
         reader.setQualitySettings(QualitySettings.getHighPerformance());
         for(BarCodeResult result : reader.readBarCodes())
           System.out.println("BarCode CodeText: " + result.getCodeText());
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         //normal quality mode is set by default
         for(BarCodeResult result : reader.readBarCodes())
           System.out.println("BarCode CodeText: " + result.getCodeText());
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         //set high performance mode
         reader.setQualitySettings(QualitySettings.getHighPerformance());
         //set separate options
         reader.getQualitySettings().setAllowMedianSmoothing(true);
         reader.getQualitySettings().setMedianSmoothingWindowSize(5);
         for(BarCodeResult result : reader.readBarCodes())
           System.out.println("BarCode CodeText: " + result.getCodeText());
         
        Value: QualitySettings to configure recognition quality and speed.
      • setQualitySettings

        public final void setQualitySettings(QualitySettings value)

        QualitySettings allows to configure recognition quality and speed manually. You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, HighQuality, MaxBarCodes or you can manually configure separate options. Default value of QualitySettings is NormalQuality.


         This sample shows how to use QualitySettings with BarCodeReader
         
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         //set high performance mode
         reader.setQualitySettings(QualitySettings.getHighPerformance());
         for(BarCodeResult result : reader.readBarCodes())
           System.out.println("BarCode CodeText: " + result.getCodeText());
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         //normal quality mode is set by default
         for(BarCodeResult result : reader.readBarCodes())
           System.out.println("BarCode CodeText: " + result.getCodeText());
         BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         //set high performance mode
         reader.setQualitySettings(QualitySettings.getHighPerformance());
         //set separate options
         reader.getQualitySettings().setAllowMedianSmoothing(true);
         reader.getQualitySettings().setMedianSmoothingWindowSize(5);
         for(BarCodeResult result : reader.readBarCodes())
           System.out.println("BarCode CodeText: " + result.getCodeText());
         
        Value: QualitySettings to configure recognition quality and speed.
      • getDetectEncoding

        public boolean getDetectEncoding()

        A flag which force engine to detect codetext encoding for Unicode codesets.


         This sample shows how to detect text encoding on the fly if DetectEncoding is enabled
         
         ByteArrayOutputStream ms = new ByteArrayOutputStream();
         BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, "�����"))
         generator.getParameters().getBarcode().getQR().setCodeTextEncoding(Charset.forName("UTF-8");
         generator.save(ms, BarCodeImageFormat.getPng());
             //detects encoding for Unicode codesets is enabled
         BarCodeReader reader = new BarCodeReader(new ByteArrayInputStream(ms.toByteArray()), DecodeType.QR);
         reader.setDetectEncoding(true);
         for(BarCodeResult result : reader.readBarCodes())
            System.out.println("BarCode CodeText: " + result.getCodeText());
             //detect encoding is disabled
         BarCodeReader reader = new BarCodeReader(new ByteArrayInputStream(ms.toByteArray()), DecodeType.QR);
         reader.setDetectEncoding(false);
         for(BarCodeResult result : reader.readBarCodes())
            System.out.println("BarCode CodeText: " + result.getCodeText());
         
      • setDetectEncoding

        public void setDetectEncoding(boolean value)

        A flag which force engine to detect codetext encoding for Unicode codesets.


         This sample shows how to detect text encoding on the fly if DetectEncoding is enabled
         
         ByteArrayOutputStream ms = new ByteArrayOutputStream();
         BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, "�����");
         generator.getParameters().getBarcode().getQR().setCodeTextEncoding(Charset.forName("UTF-8");
         generator.save(ms, BarCodeImageFormat.getPng());
         //detects encoding for Unicode codesets is enabled
         BarCodeReader reader = new BarCodeReader(new ByteArrayInputStream(ms.toByteArray()), DecodeType.QR);
         reader.setDetectEncoding(true);
         for(BarCodeResult result : reader.readBarCodes())
            System.out.println("BarCode CodeText: " + result.getCodeText());
         //detect encoding is disabled
         BarCodeReader reader = new BarCodeReader(new ByteArrayInputStream(ms.toByteArray()), DecodeType.QR);
         reader.setDetectEncoding(true);
         for(BarCodeResult result : reader.readBarCodes())
            System.out.println("BarCode CodeText: " + result.getCodeText());
         
      • setBarCodeImage

        public final void setBarCodeImage(java.awt.image.BufferedImage value,
                                          java.awt.Rectangle[] areas)

        Sets bitmap image and areas for recognition. Must be called before ReadBarCodes() method.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BufferedImage bmp = ImageIO.read(new File("c:\\test.png"));
         BarCodeReader reader = new BarCodeReader();
         reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         reader.setBarCodeImage(bmp, new Rectangle[] { new Rectangle(0, 0, bmp.getWidth(), bmp.getHeight()) });
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode Type: " + result.getCodeTypeName());
            System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        value - The bitmap image for recognition.
        areas - areas list for recognition
      • setBarCodeImage

        public final void setBarCodeImage(java.awt.image.BufferedImage value,
                                          java.awt.Rectangle area)

        Sets bitmap image and area for recognition. Must be called before ReadBarCodes() method.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BufferedImage bmp = ImageIO.read(new File("c:\\test.png"));
         BarCodeReader reader = new BarCodeReader();
         reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         reader.setBarCodeImage(bmp, new Rectangle(0, 0, bmp.getWidth(), bmp.getHeight()));
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode Type: " + result.getCodeTypeName());
            System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        value - The bitmap image for recognition.
        area - area for recognition
      • setBarCodeImage

        public final void setBarCodeImage(java.io.InputStream stream)

        Sets image stream for recognition. Must be called before ReadBarCodes() method.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         InputStream fstr = new FileInputStream(new File("c:\\test.png"));
         BarCodeReader reader = new BarCodeReader();
         reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         reader.setBarCodeImage(fstr);
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode Type: " + result.getCodeTypeName());
            System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        stream - The image stream for recogniton.
      • setBarCodeImage

        public void setBarCodeImage(java.awt.image.BufferedImage value)

        Sets bitmap image for recognition. Must be called before ReadBarCodes() method.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BufferedImage bmp = ImageIO.read(new File("c:\\test.png"));
         BarCodeReader reader = new BarCodeReader())
         {
             reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
             reader.setBarCodeImage(bmp);
             for(BarCodeResult result : reader.readBarCodes())
             {
                 System.out.println("BarCode Type: " + result.getCodeTypeName());
                 System.out.println("BarCode CodeText: " + result.getCodeText());
             }
         }
         
        Parameters:
        value - The bitmap image for recognition.
      • setBarCodeImage

        public void setBarCodeImage(java.lang.String filename)

        Sets image file for recognition. Must be called before ReadBarCodes() method.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BarCodeReader reader = new BarCodeReader())
         {
             reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
             reader.setBarCodeImage("c:\\test.png");
             for(BarCodeResult result : reader.readBarCodes())
             {
                 System.out.println("BarCode Type: " + result.getCodeTypeName());
                 System.out.println("BarCode CodeText: " + result.getCodeText());
             }
         }
         
        Parameters:
        filename - The image file for recogniton.
      • setBarCodeReadType

        public void setBarCodeReadType(SingleDecodeType... barcodeTypes)

        Sets SingleDecodeType type array for recognition. Must be called before ReadBarCodes() method.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BarCodeReader reader = new BarCodeReader();
         reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         reader.setBarCodeImage("c:\\test.png");
         for(BarCodeResult result : reader.readBarCodes())
         {
             System.out.println("BarCode Type: " + result.getCodeTypeName());
             System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        barcodeTypes - The SingleDecodeType type array to read.
      • setBarCodeReadType

        public void setBarCodeReadType(BaseDecodeType type)

        Sets decode type for recognition. Must be called before ReadBarCodes() method.


         This sample shows how to detect Code39 and Code128 barcodes.
         
         BarCodeReader reader = new BarCodeReader())
         reader.setBarCodeReadType(new MultyDecodeType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128);
         reader.setBarCodeImage("c:\\test.png");
         for(BarCodeResult result : reader.readBarCodes())
         {
            System.out.println("BarCode Type: " + result.getCodeTypeName());
            System.out.println("BarCode CodeText: " + result.getCodeText());
         }
         
        Parameters:
        type - The type of barcode to read.
      • dispose

        public void dispose()
      • exportToXml

        public boolean exportToXml(java.lang.String xmlFile)

        Exports BarCode properties to the xml-file specified

        Parameters:
        xmlFile - The name for the file
        Returns:
        Whether or not export completed successfully.

        Returns <b>True</b> in case of success; <b>False</b> Otherwise

      • exportToXml

        public boolean exportToXml(java.io.OutputStream xmlStream)
                            throws java.io.IOException

        Exports BarCode properties to the xml-stream specified

        Parameters:
        xmlStream - The xml-stream for saving
        Returns:
        Whether or not export completed successfully.

        Returns <b>True</b> in case of success; <b>False</b> Otherwise

        Throws:
        java.io.IOException
      • importFromXml

        public static BarCodeReader importFromXml(java.lang.String xmlFile)

        Imports BarCode properties from the xml-file specified and applies them to the current BarCodeBuilder instance.

        Parameters:
        xmlFile - The name for the file
        Returns:
        Returns <b>True</b> in case of success;

        <b>False</b> Otherwise

      • importFromXml

        public static BarCodeReader importFromXml(java.io.InputStream xmlStream)

        Imports BarCode properties from the xml-stream specified and applies them to the current BarCodeBuilder instance.

        Parameters:
        xmlStream - The xml-stream for loading
        Returns:
        Returns <b>True</b> in case of success;

        <b>False</b> Otherwise