public boolean applyErrorCorrection ( QrCode qr ) { // System.out.println("decoder ver "+qr.version); // System.out.println("decoder mask "+qr.mask); // System.out.println("decoder error "+qr.error); QrCode . VersionInfo info = QrCode . VERSION_INFO [ qr . version ] ; QrCode . BlockInfo block = info . levels . get ( qr . error ) ; int wordsBlockAllA = block . codewords ; int wordsBlockDataA = block . dataCodewords ; int wordsEcc = wordsBlockAllA - wordsBlockDataA ; int numBlocksA = block . blocks ; int wordsBlockAllB = wordsBlockAllA + 1 ; int wordsBlockDataB = wordsBlockDataA + 1 ; int numBlocksB = ( info . codewords - wordsBlockAllA * numBlocksA ) / wordsBlockAllB ; int totalBlocks = numBlocksA + numBlocksB ; int totalDataBytes = wordsBlockDataA * numBlocksA + wordsBlockDataB * numBlocksB ; qr . corrected = new byte [ totalDataBytes ] ; ecc . resize ( wordsEcc ) ; rscodes . generator ( wordsEcc ) ; if ( ! decodeBlocks ( qr , wordsBlockDataA , numBlocksA , 0 , 0 , totalDataBytes , totalBlocks ) ) return false ; return decodeBlocks ( qr , wordsBlockDataB , numBlocksB , numBlocksA * wordsBlockDataA , numBlocksA , totalDataBytes , totalBlocks ) ; }
Reconstruct the data while applying error correction .