Пример #1
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="o">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        override public bool Equals(Object o)
        {
            if (!(o is DataCharacter))
            {
                return(false);
            }
            DataCharacter that = (DataCharacter)o;

            return(Value == that.Value && ChecksumPortion == that.ChecksumPortion);
        }
Пример #2
0
        private Pair decodePair(BitArray row, bool right, int rowNumber, IDictionary <DecodeHintType, object> hints)
        {
            int[] startEnd = findFinderPattern(row, 0, right);
            if (startEnd == null)
            {
                return(null);
            }
            FinderPattern pattern = parseFoundFinderPattern(row, rowNumber, right, startEnd);

            if (pattern == null)
            {
                return(null);
            }

            ResultPointCallback resultPointCallback = hints == null || !hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK) ? null :
                                                      (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK];

            if (resultPointCallback != null)
            {
                float center = (startEnd[0] + startEnd[1]) / 2.0f;
                if (right)
                {
                    // row is actually reversed
                    center = row.Size - 1 - center;
                }
                resultPointCallback(new ResultPoint(center, rowNumber));
            }

            DataCharacter outside = decodeDataCharacter(row, pattern, true);

            if (outside == null)
            {
                return(null);
            }
            DataCharacter inside = decodeDataCharacter(row, pattern, false);

            if (inside == null)
            {
                return(null);
            }
            return(new Pair(1597 * outside.Value + inside.Value,
                            outside.ChecksumPortion + 4 * inside.ChecksumPortion,
                            pattern));
        }