private void DrawBarcode(Graphics g, string EncodedString, int Height, double scale, int startX, int startY) { //Start drawing at 0, 0 int XPosition = startX; int YPosition = startY; char[] CurrentSymbol = EncodedString.ToCharArray(); string EncodedSymbol; //-- draw the bars for (short j = 0; j <= Convert.ToInt16(EncodedString.Length - 1); j++) { //check if the symbol can be used EncodedSymbol = mEncoding[CurrentSymbol[j].ToString()].ToString(); for (short i = 0; i <= Convert.ToInt16(EncodedSymbol.Length - 1); i++) { //Dim CurrentCode As String = EncodedSymbol.Substring(i, 1) char CurrentCode = EncodedSymbol.ToCharArray()[i]; g.FillRectangle(getBCSymbolColor(CurrentCode), XPosition, YPosition, (int)(scale * getBCSymbolWidth(CurrentCode)), Height); XPosition = XPosition + (int)(scale * getBCSymbolWidth(CurrentCode)); } //After each written full symbol we need a whitespace (narrow width) g.FillRectangle(getBCSymbolColor('w'), XPosition, YPosition, (int)(scale * getBCSymbolWidth('w')), Height); XPosition = XPosition + (int)(scale * getBCSymbolWidth('w')); } //-------------------------- }
private void BuildLookUp(EncodedSymbol t, char symbol) { Debug.Assert(this.chars.ContainsKey(symbol) == false && this.encoded.ContainsKey(t) == false); this.chars[symbol] = t; this.encoded[t] = symbol; }
public string Decode(BitArray encoded) { int charCount = encoded.Length / MaxBits; StringBuilder sb = new StringBuilder(charCount); int arIt = 0; for (int cIt = 0; cIt < charCount; cIt++) { bool[] t = new bool[MaxBits]; for (int bT = 0; bT <= MaxBits - 1; bT++) { t[bT] = encoded[arIt + bT]; } EncodedSymbol es = new EncodedSymbol(t); arIt += MaxBits; sb.Append(this.encoded[es]); } return(sb.ToString()); }