readCodewords() {
        const formatInfo = this.readFormatInformation();
        const version = this.readVersion();
        // Get the data mask for the format used in this QR Code. This will exclude
        // some bits from reading as we wind through the bit matrix.
        const dataMask = DataMask.values.get(formatInfo.getDataMask());
        const dimension = this.bitMatrix.getHeight();
        dataMask.unmaskBitMatrix(this.bitMatrix, dimension);
        const functionPattern = version.buildFunctionPattern();
        let readingUp = true;
        const result = new Uint8Array(version.getTotalCodewords());
        let resultOffset = 0;
        let currentByte = 0;
        let bitsRead = 0;
        // Read columns in pairs, from right to left
        for (let j = dimension - 1; j > 0; j -= 2) {
            if (j === 6) {
                // Skip whole column with vertical alignment pattern
                // saves time and makes the other code proceed more cleanly
                j--;
            }
            // Read alternatingly from bottom to top then top to bottom
            for (let count = 0; count < dimension; count++) {
                const i = readingUp ? dimension - 1 - count : count;
                for (let col = 0; col < 2; col++) {
                    // Ignore bits covered by the function pattern
                    if (!functionPattern.get(j - col, i)) {
                        // Read a bit
                        bitsRead++;
                        currentByte <<= 1;
                        if (this.bitMatrix.get(j - col, i)) {
                            currentByte |= 1;
                        }
                        // If we've made a whole byte, save it off
                        if (bitsRead === 8) {
                            result[resultOffset++] = /*(byte) */ currentByte;
                            bitsRead = 0;
                            currentByte = 0;
                        }
                    }
                }
            }
            readingUp = !readingUp; // readingUp ^= true; // readingUp = !readingUp; // switch directions
        }
        if (resultOffset !== version.getTotalCodewords()) {
            throw new FormatException();
        }
        return result;
    }
/**
     * <p>Reads the bits in the {@link BitMatrix} representing the finder pattern in the
     * correct order in order to reconstruct the codewords bytes contained within the
     * QR Code.</p>
     *
     * @return bytes encoded within the QR Code
     * @throws FormatException if the exact number of bytes expected is not read
     */
Reads the bits in the  BitMatrix representing the finder pattern in the
correct order in order to reconstruct the codewords bytes contained within the
QR Code.

@return bytes encoded within the QR Code
@throws FormatException if the exact number of bytes expected is not read
Reads the bits in the BitMatrix representing the finder pattern in the correct order in order to reconstruct the codewords bytes contained within the QR Code . @return bytes encoded within the QR Code @throws FormatException if the exact number of bytes expected is not read
readCodewords() {
        const formatInfo = this.readFormatInformation();
        const version = this.readVersion();
        const dataMask = DataMask.values.get(formatInfo.getDataMask());
        const dimension = this.bitMatrix.getHeight();
        dataMask.unmaskBitMatrix(this.bitMatrix, dimension);
        const functionPattern = version.buildFunctionPattern();
        let readingUp = true;
        const result = new Uint8Array(version.getTotalCodewords());
        let resultOffset = 0;
        let currentByte = 0;
        let bitsRead = 0;
        for (let j = dimension - 1; j > 0; j -= 2) {
            if (j === 6) {
                j--;
            }
            for (let count = 0; count < dimension; count++) {
                const i = readingUp ? dimension - 1 - count : count;
                for (let col = 0; col < 2; col++) {
                    if (!functionPattern.get(j - col, i)) {
                        bitsRead++;
                        currentByte <<= 1;
                        if (this.bitMatrix.get(j - col, i)) {
                            currentByte |= 1;
                        }
                        if (bitsRead === 8) {
                            result[resultOffset++] =  currentByte;
                            bitsRead = 0;
                            currentByte = 0;
                        }
                    }
                }
            }
            readingUp = !readingUp; 
        }
        if (resultOffset !== version.getTotalCodewords()) {
            throw new FormatException();
        }
        return result;
    }
readCodewords ( ) { const formatInfo = this . readFormatInformation ( ) ; const version = this . readVersion ( ) ; const dataMask = DataMask . values . get ( formatInfo . getDataMask ( ) ) ; const dimension = this . bitMatrix . getHeight ( ) ; dataMask . unmaskBitMatrix ( this . bitMatrix , dimension ) ; const functionPattern = version . buildFunctionPattern ( ) ; let readingUp = true ; const result = new Uint8Array ( version . getTotalCodewords ( ) ) ; let resultOffset = 0 ; let currentByte = 0 ; let bitsRead = 0 ; for ( let j = dimension - 1 ; j > 0 ; j -= 2 ) { if ( j === 6 ) { j -- ; } for ( let count = 0 ; count < dimension ; count ++ ) { const i = readingUp ? dimension - 1 - count : count ; for ( let col = 0 ; col < 2 ; col ++ ) { if ( ! functionPattern . get ( j - col , i ) ) { bitsRead ++ ; currentByte <<= 1 ; if ( this . bitMatrix . get ( j - col , i ) ) { currentByte |= 1 ; } if ( bitsRead === 8 ) { result [ resultOffset ++ ] = currentByte ; bitsRead = 0 ; currentByte = 0 ; } } } } readingUp = ! readingUp ; } if ( resultOffset !== version . getTotalCodewords ( ) ) { throw new FormatException ( ) ; } return result ; }
<p>Reads the bits in the {@link BitMatrix} representing the finder pattern in the
 correct order in order to reconstruct the codewords bytes contained within the
 QR Code.</p>
<p > Reads the bits in the { @link BitMatrix } representing the finder pattern in the correct order in order to reconstruct the codewords bytes contained within the QR Code . < / p >
// Get the data mask for the format used in this QR Code. This will exclude // some bits from reading as we wind through the bit matrix. // Read columns in pairs, from right to left // Skip whole column with vertical alignment pattern // saves time and makes the other code proceed more cleanly // Read alternatingly from bottom to top then top to bottom // Ignore bits covered by the function pattern // Read a bit // If we've made a whole byte, save it off /*(byte) */ // readingUp ^= true; // readingUp = !readingUp; // switch directions