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 bool IsCharValid(char character) { return(PDF417.GetNumberOfBytesAtPosition(character.ToString(), 0) + PDF417.GetNumberOfCharsAtPosition(character.ToString(), 0) + PDF417.GetNumberOfDigitsAtPosition(character.ToString(), 0) > 0); }