You are on page 1of 2

namespace PDF417ClassLibrary

{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/// <summary>
/// TODO: Update summary.
/// </summary>
internal static class ErrorCorrectionGenerator
{
internal static List<long> GenerateErrorCo
rrectionSequence(List<long> dataCodeWords, int err
orCorrectionLevel)
{
int errorCorrectionCount = Specificati
onData.ErrorCorrectionLevels[errorCorrectionLevel]
.Count;
long temp1, temp2, temp3;
List<long> errorCorrectionCodeWords = n
ew List<long>(errorCorrectionCount);
for (int index = 0; index < errorCorrec
tionCount; index++)
errorCorrectionCodeWords.Add(0);
foreach (int dataCodeWord in dataCodeWo
rds)
{
temp1 = (dataCodeWord + errorCorre
ctionCodeWords[errorCorrectionCount - 1]) % 929;
for (int index = errorCorrectionCod
eWords.Count - 1; index > 0; index--)
{
temp2 = (temp1 * Specification
Data.ErrorCorrectionLevels[errorCorrectionLevel][i
ndex]) % 929;
temp3 = 929 - temp2;
errorCorrectionCodeWords[index

] = (errorCorrectionCodeWords[index - 1] + temp3)
% 929;
}
temp2 = (temp1 * SpecificationData
.ErrorCorrectionLevels[errorCorrectionLevel][0]) %
929;
temp3 = 929 - temp2;
errorCorrectionCodeWords[0] = temp
3 % 929;
}
for (int index = 0; index < errorCorrec
tionCodeWords.Count; index++)
{
if (errorCorrectionCodeWords[index]
!= 0)
errorCorrectionCodeWords[index] = 9
29 - errorCorrectionCodeWords[index];
}
errorCorrectionCodeWords.Reverse();
return errorCorrectionCodeWords;
}
}
}

You might also like