iTextSharp.text.pdf.BarcodePDF417.PaintCode C# (CSharp) Метод

PaintCode() публичный Метод

public PaintCode ( ) : void
Результат void
        public void PaintCode() {
            int maxErr, lenErr, tot, pad;
            if ((options & PDF417_USE_RAW_CODEWORDS) != 0) {
                if (lenCodewords > MAX_DATA_CODEWORDS || lenCodewords < 1 || lenCodewords != codewords[0]) {
                    throw new ArgumentException("Invalid codeword size.");
                }
            }
            else {
                if (text == null)
                    throw new ArgumentNullException("Text cannot be null.");
                if (text.Length > ABSOLUTE_MAX_TEXT_SIZE) {
                    throw new ArgumentOutOfRangeException("The text is too big.");
                }
                segmentList = new SegmentList();
                BreakString();
                //dumpList();
                Assemble();
                segmentList = null;
                codewords[0] = lenCodewords = cwPtr;
            }
            maxErr = MaxPossibleErrorLevel(MAX_DATA_CODEWORDS + 2 - lenCodewords);
            if ((options & PDF417_USE_ERROR_LEVEL) == 0) {
                if (lenCodewords < 41)
                    errorLevel = 2;
                else if (lenCodewords < 161)
                    errorLevel = 3;
                else if (lenCodewords < 321)
                    errorLevel = 4;
                else
                    errorLevel = 5;
            }
            if (errorLevel < 0)
                errorLevel = 0;
            else if (errorLevel > maxErr)
                errorLevel = maxErr;
            if (codeColumns < 1)
                codeColumns = 1;
            else if (codeColumns > 30)
                codeColumns = 30;
            if (codeRows < 3)
                codeRows = 3;
            else if (codeRows > 90)
                codeRows = 90;
            lenErr = 2 << errorLevel;
            bool fixedColumn = (options & PDF417_FIXED_ROWS) == 0;
            bool skipRowColAdjust = false;
            tot = lenCodewords + lenErr;
            if ((options & PDF417_FIXED_RECTANGLE) != 0) {
                tot = codeColumns * codeRows;
                if (tot > MAX_DATA_CODEWORDS + 2) {
                    tot = GetMaxSquare();
                }
                if (tot < lenCodewords + lenErr)
                    tot = lenCodewords + lenErr;
                else
                    skipRowColAdjust = true;
            }
            else if ((options & (PDF417_FIXED_COLUMNS | PDF417_FIXED_ROWS)) == 0) {
                double c, b;
                fixedColumn = true;
                if (aspectRatio < 0.001)
                    aspectRatio = 0.001f;
                else if (aspectRatio > 1000)
                    aspectRatio = 1000;
                b = 73 * aspectRatio - 4;
                c = (-b + Math.Sqrt(b * b + 4 * 17 * aspectRatio * (lenCodewords + lenErr) * yHeight)) / (2 * 17 * aspectRatio);
                codeColumns = (int)(c + 0.5);
                if (codeColumns < 1)
                    codeColumns = 1;
                else if (codeColumns > 30)
                    codeColumns = 30;
            }
            if (!skipRowColAdjust) {
                if (fixedColumn) {
                    codeRows = (tot - 1) / codeColumns + 1;
                    if (codeRows < 3)
                        codeRows = 3;
                    else if (codeRows > 90) {
                        codeRows = 90;
                        codeColumns = (tot - 1) / 90 + 1;
                    }
                }
                else {
                    codeColumns = (tot - 1) / codeRows + 1;
                    if (codeColumns > 30) {
                        codeColumns = 30;
                        codeRows = (tot - 1) / 30 + 1;
                    }
                }
                tot = codeRows * codeColumns;
            }
            if (tot > MAX_DATA_CODEWORDS + 2) {
                tot = GetMaxSquare();
            }
            errorLevel = MaxPossibleErrorLevel(tot - lenCodewords);
            lenErr = 2 << errorLevel;
            pad = tot - lenErr - lenCodewords;
            if ((options & PDF417_USE_MACRO) != 0) {
                // the padding comes before the control block
                System.Array.Copy(codewords, macroIndex, codewords, macroIndex + pad, pad);
                cwPtr = lenCodewords + pad;
                while (pad-- != 0)
                    codewords[macroIndex++] = TEXT_MODE;
            }
            else {
                cwPtr = lenCodewords;
                while (pad-- != 0)
                    codewords[cwPtr++] = TEXT_MODE;
            }
            codewords[0] = lenCodewords = cwPtr;
            CalculateErrorCorrection(lenCodewords);
            lenCodewords = tot;
            OutPaintCode();
        }