iTextSharp.text.pdf.qrcode.MatrixUtil.MakeTypeInfoBits C# (CSharp) Method

MakeTypeInfoBits() public static method

public static MakeTypeInfoBits ( ErrorCorrectionLevel ecLevel, int maskPattern, BitVector bits ) : void
ecLevel ErrorCorrectionLevel
maskPattern int
bits BitVector
return void
        public static void MakeTypeInfoBits(ErrorCorrectionLevel ecLevel, int maskPattern, BitVector bits) {
            if (!QRCode.IsValidMaskPattern(maskPattern)) {
                throw new WriterException("Invalid mask pattern");
            }
            int typeInfo = (ecLevel.GetBits() << 3) | maskPattern;
            bits.AppendBits(typeInfo, 5);

            int bchCode = CalculateBCHCode(typeInfo, TYPE_INFO_POLY);
            bits.AppendBits(bchCode, 10);

            BitVector maskBits = new BitVector();
            maskBits.AppendBits(TYPE_INFO_MASK_PATTERN, 15);
            bits.Xor(maskBits);

            if (bits.Size() != 15) {  // Just in case.
                throw new WriterException("should not happen but we got: " + bits.Size());
            }
        }