コード例 #1
0
ファイル: QRCode.cs プロジェクト: Niladri24dutta/itextsharp
 public QRCode() {
     mode = null;
     ecLevel = null;
     version = -1;
     matrixWidth = -1;
     maskPattern = -1;
     numTotalBytes = -1;
     numDataBytes = -1;
     numECBytes = -1;
     numRSBlocks = -1;
     matrix = null;
 }
コード例 #2
0
ファイル: Encoder.cs プロジェクト: Niladri24dutta/itextsharp
 /**
  * Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits".
  */
 static void AppendBytes(String content, Mode mode, BitVector bits, String encoding) {
     if (mode.Equals(Mode.NUMERIC)) {
         AppendNumericBytes(content, bits);
     }
     else if (mode.Equals(Mode.ALPHANUMERIC)) {
         AppendAlphanumericBytes(content, bits);
     }
     else if (mode.Equals(Mode.BYTE)) {
         Append8BitBytes(content, bits, encoding);
     }
     else if (mode.Equals(Mode.KANJI)) {
         AppendKanjiBytes(content, bits);
     }
     else {
         throw new WriterException("Invalid mode: " + mode);
     }
 }
コード例 #3
0
ファイル: Encoder.cs プロジェクト: Niladri24dutta/itextsharp
 /**
  * Append length info. On success, store the result in "bits".
  */
 static void AppendLengthInfo(int numLetters, int version, Mode mode, BitVector bits) {
     int numBits = mode.GetCharacterCountBits(Version.GetVersionForNumber(version));
     if (numLetters > ((1 << numBits) - 1)) {
         throw new WriterException(numLetters + "is bigger than" + ((1 << numBits) - 1));
     }
     bits.AppendBits(numLetters, numBits);
 }
コード例 #4
0
ファイル: Encoder.cs プロジェクト: Niladri24dutta/itextsharp
 /**
  * Append mode info. On success, store the result in "bits".
  */
 static void AppendModeInfo(Mode mode, BitVector bits) {
     bits.AppendBits(mode.GetBits(), 4);
 }
コード例 #5
0
ファイル: Encoder.cs プロジェクト: Niladri24dutta/itextsharp
        /**
         * Initialize "qrCode" according to "numInputBytes", "ecLevel", and "mode". On success,
         * modify "qrCode".
         */
        private static void InitQRCode(int numInputBytes, ErrorCorrectionLevel ecLevel, Mode mode,
            QRCode qrCode) {
            qrCode.SetECLevel(ecLevel);
            qrCode.SetMode(mode);

            // In the following comments, we use numbers of Version 7-H.
            for (int versionNum = 1; versionNum <= 40; versionNum++) {
                Version version = Version.GetVersionForNumber(versionNum);
                // numBytes = 196
                int numBytes = version.GetTotalCodewords();
                // getNumECBytes = 130
                Version.ECBlocks ecBlocks = version.GetECBlocksForLevel(ecLevel);
                int numEcBytes = ecBlocks.GetTotalECCodewords();
                // getNumRSBlocks = 5
                int numRSBlocks = ecBlocks.GetNumBlocks();
                // getNumDataBytes = 196 - 130 = 66
                int numDataBytes = numBytes - numEcBytes;
                // We want to choose the smallest version which can contain data of "numInputBytes" + some
                // extra bits for the header (mode info and length info). The header can be three bytes
                // (precisely 4 + 16 bits) at most. Hence we do +3 here.
                if (numDataBytes >= numInputBytes + 3) {
                    // Yay, we found the proper rs block info!
                    qrCode.SetVersion(versionNum);
                    qrCode.SetNumTotalBytes(numBytes);
                    qrCode.SetNumDataBytes(numDataBytes);
                    qrCode.SetNumRSBlocks(numRSBlocks);
                    // getNumECBytes = 196 - 66 = 130
                    qrCode.SetNumECBytes(numEcBytes);
                    // matrix width = 21 + 6 * 4 = 45
                    qrCode.SetMatrixWidth(version.GetDimensionForVersion());
                    return;
                }
            }
            throw new WriterException("Cannot find proper rs block info (input data too big?)");
        }
コード例 #6
0
ファイル: QRCode.cs プロジェクト: karino2/wikipediaconv
 public void SetMode(Mode value)
 {
     mode = value;
 }