コード例 #1
0
ファイル: Detector.cs プロジェクト: domicioam/NFeFacilLegacy
        /// <summary> <p>Computes the dimension (number of modules on a size) of the QR Code based on the position
        /// of the finder patterns and estimated module size.</p>
        /// </summary>
        private static bool ComputeDimension(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft, float moduleSize, out int dimension)
        {
            int tltrCentersDimension = MathUtils.Round(ResultPoint.Distance(topLeft, topRight) / moduleSize);
            int tlblCentersDimension = MathUtils.Round(ResultPoint.Distance(topLeft, bottomLeft) / moduleSize);

            dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7;
            switch (dimension & 0x03)
            {
            // mod 4
            case 0:
                dimension++;
                break;

            // 1? do nothing
            case 2:
                dimension--;
                break;

            case 3:
                return(true);
            }
            return(true);
        }