示例#1
0
 internal virtual DecodeResult decode(QRCodeImage qrCodeImage, Point adjust)
 {
     try
     {
         if (numTryDecode == 0)
         {
             canvas.println("Decoding started");
             int[][] intImage = imageToIntArray(qrCodeImage);
             imageReader  = new QRCodeImageReader();
             qrCodeSymbol = imageReader.getQRCodeSymbol(intImage);
         }
         else
         {
             canvas.println("--");
             canvas.println("Decoding restarted #" + (numTryDecode));
             qrCodeSymbol = imageReader.getQRCodeSymbolWithAdjustedGrid(adjust);
         }
     }
     catch (SymbolNotFoundException e)
     {
         throw new DecodingFailedException(e.Message);
     }
     canvas.println("Created QRCode symbol.");
     canvas.println("Reading symbol.");
     canvas.println("Version: " + qrCodeSymbol.VersionReference);
     canvas.println("Mask pattern: " + qrCodeSymbol.MaskPatternRefererAsString);
     // blocks contains all (data and RS) blocks in QR Code symbol
     int[] blocks = qrCodeSymbol.Blocks;
     canvas.println("Correcting data errors.");
     // now blocks turn to data blocks (corrected and extracted from original blocks)
     blocks = correctDataBlocks(blocks);
     try
     {
         sbyte[] decodedByteArray = getDecodedByteArray(blocks, qrCodeSymbol.Version, qrCodeSymbol.NumErrorCollectionCode);
         return(new DecodeResult(this, decodedByteArray, numLastCorrections, correctionSucceeded));
     }
     catch (InvalidDataBlockException e)
     {
         canvas.println(e.Message);
         throw new DecodingFailedException(e.Message);
     }
 }
示例#2
0
 internal virtual DecodeResult Decode(QRCodeImage qrCodeImage, Point adjust)
 {
     try
     {
         if (numTryDecode == 0)
         {
             canvas.Print("Decoding started");
             int[][] intImage = imageToIntArray(qrCodeImage);
             imageReader = new QRCodeImageReader();
             qrCodeSymbol = imageReader.GetQRCodeSymbol(intImage);
         }
         else
         {
             canvas.Print("--");
             canvas.Print("Decoding restarted #" + (numTryDecode));
             qrCodeSymbol = imageReader.GetQRCodeSymbolWithAdjustedGrid(adjust);
         }
     }
     catch (SymbolNotFoundException e)
     {
         throw new DecodingFailedException(e.Message);
     }
     canvas.Print("Created QRCode symbol.");
     canvas.Print("Reading symbol.");
     canvas.Print("Version: " + qrCodeSymbol.VersionReference);
     canvas.Print("Mask pattern: " + qrCodeSymbol.MaskPatternRefererAsString);
     // blocks contains all (data and RS) blocks in QR Code symbol
     int[] blocks = qrCodeSymbol.Blocks;
     canvas.Print("Correcting data errors.");
     // now blocks turn to data blocks (corrected and extracted from original blocks)
     blocks = CorrectDataBlocks(blocks);
     try
     {
         sbyte[] decodedByteArray = GetDecodedByteArray(blocks, qrCodeSymbol.Version, qrCodeSymbol.NumErrorCollectionCode);
         return new DecodeResult(this, decodedByteArray, numLastCorrectionFailures);
     }
     catch (InvalidDataBlockException e)
     {
         canvas.Print(e.Message);
         throw new DecodingFailedException(e.Message);
     }
 }