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

EmbedTypeInfo() public static method

public static EmbedTypeInfo ( ErrorCorrectionLevel ecLevel, int maskPattern, ByteMatrix matrix ) : void
ecLevel ErrorCorrectionLevel
maskPattern int
matrix ByteMatrix
return void
        public static void EmbedTypeInfo(ErrorCorrectionLevel ecLevel, int maskPattern, ByteMatrix matrix) {
            BitVector typeInfoBits = new BitVector();
            MakeTypeInfoBits(ecLevel, maskPattern, typeInfoBits);

            for (int i = 0; i < typeInfoBits.Size(); ++i) {
                // Place bits in LSB to MSB order.  LSB (least significant bit) is the last value in
                // "typeInfoBits".
                int bit = typeInfoBits.At(typeInfoBits.Size() - 1 - i);

                // Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46).
                int x1 = TYPE_INFO_COORDINATES[i][0];
                int y1 = TYPE_INFO_COORDINATES[i][1];
                matrix.Set(x1, y1, bit);

                if (i < 8) {
                    // Right top corner.
                    int x2 = matrix.GetWidth() - i - 1;
                    int y2 = 8;
                    matrix.Set(x2, y2, bit);
                }
                else {
                    // Left bottom corner.
                    int x2 = 8;
                    int y2 = matrix.GetHeight() - 7 + (i - 8);
                    matrix.Set(x2, y2, bit);
                }
            }
        }