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

2019-12-26 13:16:00王振洲
  • float height = (this._moduleHeight + (2f * this._marginY)) + fontsize;  width *= resolution / 25.4f; 
  • height *= resolution / 25.4f;  Bitmap image = new Bitmap((int)width, (int)height, PixelFormat.Format32bppPArgb); 
  • image.SetResolution(resolution, resolution);  //image.SetResolution(300, 300); 
  • Graphics g = Graphics.FromImage(image);  g.Clear(Color.White); 
  • g.PageUnit = GraphicsUnit.Millimeter; //以毫米为度量单位  g.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, /*(int)width*/image.Width, /*(int)height*/image.Height)); 
  • //new Pen(Color.Black, 2f);  //new SolidBrush(Color.White); 
  • SolidBrush brush = new SolidBrush(Color.Black);  if (resolution < 300f) 
  • {  //g.TextRenderingHint = TextRenderingHint.AntiAlias; 
  • //g.SmoothingMode = SmoothingMode.AntiAlias;  g.CompositingQuality = CompositingQuality.HighQuality; 
  • //g.SmoothingMode = SmoothingMode.HighQuality;  g.InterpolationMode = InterpolationMode.HighQualityBicubic; 
  • g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;  } 
  • float num7 = 0f;  for (num6 = 0; num6 < chArray.Length; num6++) 
  • {  if (chArray[num6] == '0') 
  • {  if ((num6 & 1) != 1) 
  • {  RectangleF rect = new RectangleF(MarginX + num7, MarginY, ModuleWidth, ModuleHeight); 
  • MakeBar(g, rect, Reduction);  } 
  • num7 += 1f * ModuleWidth;  } 
  • else  { 
  • if ((num6 & 1) != 1)  { 
  • RectangleF ef2 = new RectangleF(MarginX + num7, MarginY, Ratio * ModuleWidth, ModuleHeight);  MakeBar(g, ef2, Reduction); 
  • }  num7 += Ratio * ModuleWidth; 
  • }  } 
  • #region 供人识别内容  if (this._humanReadable) 
  • {  #region 保留