private void EncodeTextCompleteString(string text) { TextMode textMode = new TextMode(); text = PDF417.ValidateText(text); this.encodedRawData.AddRange((IEnumerable <long>)textMode.EncodeData(text, false)); }
private static void DetermineNextMode(string text, ref bool shouldApplyNonLatchData) { if (PDF417.GetNumberOfCharsAtPosition(text, 0) >= 5 || PDF417.GetNumberOfBytesAtPosition(text, 0) == 1) { return; } shouldApplyNonLatchData = true; }
public void PopulateMatrix( string text, int errorCorrectionLevel, EncodingMode mode, int columns, int rows) { this.encodedRawData = new List <long>(); this.xRatio = this.GetValidValue(columns, 3, 30); this.yRatio = this.GetValidValue(rows, 2, 90); this.eCLevel = errorCorrectionLevel; this.eCCount = SpecificationData.ErrorCorrectionLevels[this.eCLevel].Count; switch (mode) { case EncodingMode.Auto: text = PDF417.ValidateTextModeNone(text); int dataIndex = 0; while (dataIndex < text.Length) { int digitsAtPosition = PDF417.GetNumberOfDigitsAtPosition(text, dataIndex); if (digitsAtPosition >= 13) { this.EncodeNumeric(text, ref dataIndex, digitsAtPosition); } else if (digitsAtPosition < 13) { int ofCharsAtPosition = PDF417.GetNumberOfCharsAtPosition(text, dataIndex); if (ofCharsAtPosition >= 5) { this.EncodeText(text, ref dataIndex, ofCharsAtPosition); } else if (ofCharsAtPosition < 5) { int ofBytesAtPosition = PDF417.GetNumberOfBytesAtPosition(text, dataIndex); this.EncodeByte(text, ref dataIndex, ofBytesAtPosition); } } } break; case EncodingMode.Text: this.EncodeTextCompleteString(text); break; case EncodingMode.Numeric: this.EncodeNumericCompleteString(text); break; default: this.EncodeByteCompleteString(text); break; } this.SetSmallestSizeOfMatrix(); this.VerifyDataLength(); this.PadData(); this.SetErrorCorrection(); this.FillMatrixWithData(); }
private static int GetNumberOfCharsAtPosition(string text, int currentPosition) { int num = 0; while (currentPosition <= text.Length - 1 && PDF417.GetNumberOfDigitsAtPosition(text, currentPosition) < 13 && TextMode.FindCharacterInTable((int)text[currentPosition]) != null) { ++currentPosition; ++num; } return(num); }
private static int GetNumberOfBytesAtPosition(string text, int currentPosition) { int num = 0; while (currentPosition <= text.Length - 1 && PDF417.GetNumberOfDigitsAtPosition(text, currentPosition) < 13 && (PDF417.GetNumberOfCharsAtPosition(text, currentPosition) < 5 && SpecificationData.ByteModeValues.Contains((int)text[currentPosition]))) { ++currentPosition; ++num; } return(num); }
private static string ValidateTextModeNone(string text) { string empty = string.Empty; for (int index = 0; index < text.Length; ++index) { if (PDF417.IsCharValid(text[index])) { empty += (string)(object)text[index]; } } return(empty); }
private void EncodeText(string text, ref int dataIndex, int numberOfTexModeCharsAtPosition) { TextMode textMode = new TextMode(); int startIndex = dataIndex + numberOfTexModeCharsAtPosition; bool shouldApplyNonLatchData = false; if (startIndex < text.Length - 1) { PDF417.DetermineNextMode(text.Substring(startIndex), ref shouldApplyNonLatchData); } this.encodedRawData.Add(900L); this.encodedRawData.AddRange((IEnumerable <long>)textMode.EncodeData(text.Substring(dataIndex, numberOfTexModeCharsAtPosition), shouldApplyNonLatchData)); dataIndex += numberOfTexModeCharsAtPosition; }
private void AddDataCluster(int rowIndex, int columnIndex, int dataPointer) { int clusterIndex = PDF417.CalculateClusterIndex(rowIndex); string str = SpecificationData.BarSpaceSequence[(int)this.encodedRawData[dataPointer]][clusterIndex].ToString(); for (int index1 = 0; index1 < str.Length; ++index1) { bool flag = index1 % 2 == 0; for (int index2 = 0; index2 < int.Parse(str[index1].ToString()); ++index2) { this.dataMatrix[rowIndex, columnIndex] = flag; ++columnIndex; } } }
private void AddRightRowIndicatorCluster(int rowIndex, int columnIndex) { int clusterIndex = PDF417.CalculateClusterIndex(rowIndex); int rightRowIndicator = PDF417.CalculateRightRowIndicator(clusterIndex, rowIndex, this.rows, this.columns, this.eCLevel); string str = SpecificationData.BarSpaceSequence[rightRowIndicator][clusterIndex].ToString(); for (int index1 = 0; index1 < str.Length; ++index1) { bool flag = index1 % 2 == 0; for (int index2 = 0; index2 < int.Parse(str[index1].ToString()); ++index2) { this.dataMatrix[rowIndex, columnIndex] = flag; ++columnIndex; } } }
private void EncodeByteCompleteString(string text) { text = PDF417.ValidateByte(text); this.encodedRawData.AddRange((IEnumerable <long>)ByteMode.EncodeText(text)); }
private void EncodeNumericCompleteString(string text) { text = PDF417.ValidateDigits(text); this.encodedRawData.Add(902L); this.encodedRawData.AddRange((IEnumerable <long>)NumericMode.EncodeData(text)); }
private static bool IsCharValid(char character) { return(PDF417.GetNumberOfBytesAtPosition(character.ToString(), 0) + PDF417.GetNumberOfCharsAtPosition(character.ToString(), 0) + PDF417.GetNumberOfDigitsAtPosition(character.ToString(), 0) > 0); }