示例#1
0
        /// <summary> See ISO 18004:2006 Annex E</summary>
        internal BitMatrix buildFunctionPattern()
        {
            int       dimension = DimensionForVersion;
            BitMatrix bitMatrix = new BitMatrix(dimension);

            // Top left finder pattern + separator + format
            bitMatrix.setRegion(0, 0, 9, 9);

            // Vertical timing pattern
            bitMatrix.setRegion(9, 0, dimension - 9, 1);
            // Horizontal timing pattern
            bitMatrix.setRegion(0, 9, 1, dimension - 9);

            return(bitMatrix);
        }
示例#2
0
        /// <summary> See ISO 18004:2006 Annex E</summary>
        internal BitMatrix buildFunctionPattern()
        {
            int       dimension = DimensionForVersion;
            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);
        }
示例#3
0
        /// <summary> See ISO 18004:2006 Annex E</summary>
        internal BitMatrix buildFunctionPattern()
        {
            int dimension = DimensionForVersion;
            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;
        }
示例#4
0
        /// <summary> See ISO 18004:2006 Annex E</summary>
        internal BitMatrix buildFunctionPattern()
        {
            int dimension = DimensionForVersion;
            BitMatrix bitMatrix = new BitMatrix(dimension);

            // Top left finder pattern + separator + format
            bitMatrix.setRegion(0, 0, 9, 9);

            // Vertical timing pattern
            bitMatrix.setRegion(9, 0, dimension - 9, 1);
            // Horizontal timing pattern
            bitMatrix.setRegion(0, 9, 1, dimension - 9);

            return bitMatrix;
        }
        // Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses
        // 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
        private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone)
        {
            ByteMatrix input = code.Matrix;
            if (input == null)
            {
              throw new InvalidOperationException();
            }
            int inputWidth = input.Width;
            int inputHeight = input.Height;
            int qrWidth = inputWidth + (quietZone << 1);
            int qrHeight = inputHeight + (quietZone << 1);
            int outputWidth = Math.Max(width, qrWidth);
            int outputHeight = Math.Max(height, qrHeight);

            int multiple = Math.Min(outputWidth / qrWidth, outputHeight / qrHeight);
            // Padding includes both the quiet zone and the extra white pixels to accommodate the requested
            // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
            // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
            // handle all the padding from 100x100 (the actual QR) up to 200x160.
            int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
            int topPadding = (outputHeight - (inputHeight * multiple)) / 2;

            BitMatrix output = new BitMatrix(outputWidth, outputHeight);

            for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple)
            {
              // Write the contents of this row of the barcode
              for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple)
              {
            if (input.get(inputX, inputY) == 1)
            {
              output.setRegion(outputX, outputY, multiple, multiple);
            }
              }
            }

            return output;
        }