C#生成Code39条形码而非条形码字体的方法

2019-12-26 13:16:00王振洲
  • /*byte[] buffer2 = processTilde(this._dataToEncode);  int index = 0; 
  • List<byte> arr = new List<byte>();  for (num6 = 0; num6 < buffer2.Length; num6++) 
  • {  //0x20 32 0x7e 126 
  • if ((buffer2[num6] >= 0x20) && (buffer2[num6] <= 0x7e))  { 
  • arr.Add(buffer2[num6]);  } 
  • }  byte[] bytes = new byte[arr.Count]; 
  • for (int i = 0; i < arr.Count; i++)  { 
  • bytes[i] = arr[i];  } 
  • index = arr.Count;  //string text = new ASCIIEncoding().GetString(bytes, 0, index); 
  • */  #endregion 
  • string text = this._dataToEncode;  if (this._isDisplayCheckCode&&!string.IsNullOrEmpty(this._checkData)) { 
  • text += this._checkData;  } 
  • if (this._isDisplayStartStopSign)  { 
  • text = "*" + text + "*";  } 
  • Font font = new Font(this._humanReadableFont, this._humanReadableSize);  //g.DrawString(text, font, brush, new PointF(MarginX, MarginY + ModuleHeight)); 
  • //新增字符串格式  var drawFormat = new StringFormat { Alignment = StringAlignment.Center }; 
  • float inpix = image.Width / resolution;//根据DPi求出 英寸数  float widthmm = inpix * 25.4f; //有每英寸像素求出毫米 
  • //g.DrawString(text, font, Brushes.Black, width / 2, height - 14, drawFormat);  g.DrawString(text, font, /*Brushes.Black*/brush, new PointF(/*MarginX*/(int)(widthmm / 2), MarginY + ModuleHeight + 1), drawFormat); 
  • }  #endregion 
  •   return image; 
  • }  /// <summary> 
  • /// 进行图形填充  /// </summary> 
  • /// <param name="g"></param>  /// <param name="rect"></param> 
  • /// <param name="reduction"></param>  private void MakeBar(Graphics g, RectangleF rect, float reduction)