iTextSharp.text.pdf.qrcode.BitMatrix.SetRegion C# (CSharp) Метод

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

public SetRegion ( int left, int top, int width, int height ) : void
left int
top int
width int
height int
Результат void
        public void SetRegion(int left, int top, int width, int height) {
            if (top < 0 || left < 0) {
                throw new ArgumentException("Left and top must be nonnegative");
            }
            if (height < 1 || width < 1) {
                throw new ArgumentException("Height and width must be at least 1");
            }
            int right = left + width;
            int bottom = top + height;
            if (bottom > this.height || right > this.width) {
                throw new ArgumentException("The region must fit inside the matrix");
            }
            for (int y = top; y < bottom; y++) {
                int offset = y * rowSize;
                for (int x = left; x < right; x++) {
                    bits[offset + (x >> 5)] |= 1 << (x & 0x1f);
                }
            }
        }

Usage Example

Пример #1
0
        /**
         * See ISO 18004:2006 Annex E
         */
        BitMatrix BuildFunctionPattern()
        {
            int       dimension = GetDimensionForVersion();
            BitMatrix bitMatrix = new BitMatrix(dimension);

            // Top left finder pattern + separator + format
            bitMatrix.SetRegion(0, 0, 9, 9);
            // Top right finder pattern + separator + format
            bitMatrix.SetRegion(dimension - 8, 0, 8, 9);
            // Bottom left finder pattern + separator + format
            bitMatrix.SetRegion(0, dimension - 8, 9, 8);

            // Alignment patterns
            int max = alignmentPatternCenters.Length;

            for (int x = 0; x < max; x++)
            {
                int i = alignmentPatternCenters[x] - 2;
                for (int y = 0; y < max; y++)
                {
                    if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0))
                    {
                        // No alignment patterns near the three finder paterns
                        continue;
                    }
                    bitMatrix.SetRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
                }
            }

            // Vertical timing pattern
            bitMatrix.SetRegion(6, 9, 1, dimension - 17);
            // Horizontal timing pattern
            bitMatrix.SetRegion(9, 6, dimension - 17, 1);

            if (versionNumber > 6)
            {
                // Version info, top right
                bitMatrix.SetRegion(dimension - 11, 0, 3, 6);
                // Version info, bottom left
                bitMatrix.SetRegion(0, dimension - 11, 6, 3);
            }

            return(bitMatrix);
        }
All Usage Examples Of iTextSharp.text.pdf.qrcode.BitMatrix::SetRegion