Ejemplo n.º 1
0
      private static Result constructResult(Pair leftPair, Pair rightPair)
      {
         long symbolValue = 4537077L * leftPair.Value + rightPair.Value;
         String text = symbolValue.ToString();

         StringBuilder buffer = new StringBuilder(14);
         for (int i = 13 - text.Length; i > 0; i--)
         {
            buffer.Append('0');
         }
         buffer.Append(text);

         int checkDigit = 0;
         for (int i = 0; i < 13; i++)
         {
            int digit = buffer[i] - '0';
            checkDigit += (i & 0x01) == 0 ? 3 * digit : digit;
         }
         checkDigit = 10 - (checkDigit % 10);
         if (checkDigit == 10)
         {
            checkDigit = 0;
         }
         buffer.Append(checkDigit);

         ResultPoint[] leftPoints = leftPair.FinderPattern.ResultPoints;
         ResultPoint[] rightPoints = rightPair.FinderPattern.ResultPoints;
         return new Result(
             buffer.ToString(),
             null,
             new ResultPoint[] { leftPoints[0], leftPoints[1], rightPoints[0], rightPoints[1], },
             BarcodeFormat.RSS_14);
      }
Ejemplo n.º 2
0
 private static bool checkChecksum(Pair leftPair, Pair rightPair)
 {
    //int leftFPValue = leftPair.FinderPattern.Value;
    //int rightFPValue = rightPair.FinderPattern.Value;
    //if ((leftFPValue == 0 && rightFPValue == 8) ||
    //    (leftFPValue == 8 && rightFPValue == 0))
    //{
    //}
    int checkValue = (leftPair.ChecksumPortion + 16 * rightPair.ChecksumPortion) % 79;
    int targetCheckValue =
        9 * leftPair.FinderPattern.Value + rightPair.FinderPattern.Value;
    if (targetCheckValue > 72)
    {
       targetCheckValue--;
    }
    if (targetCheckValue > 8)
    {
       targetCheckValue--;
    }
    return checkValue == targetCheckValue;
 }
Ejemplo n.º 3
0
 private static void addOrTally(IList<Pair> possiblePairs, Pair pair)
 {
    if (pair == null)
    {
       return;
    }
    bool found = false;
    foreach (Pair other in possiblePairs)
    {
       if (other.Value == pair.Value)
       {
          other.incrementCount();
          found = true;
          break;
       }
    }
    if (!found)
    {
       possiblePairs.Add(pair);
    }
 }