TBarCode .NET 常见问题
如何创建清晰可读的 Code 39 位图?
如何创建清晰可读的 Code 39 位图?
以下 ASP .NET 示例代码生成了一个 Code 39 图像。
//Code 39 Barcode barcode = new Barcode(); barcode.Data = "10030000007611107871900002199908"; barcode.BarcodeType = BarcodeType.Code39; // with dpi = 100 we get 1 Pixel = 0.254 mms barcode.Dpi = 100; // bar code size should adapt to bounding rectangle barcode.SizeMode = SizeMode.FitToBoundingRectangle; // set default size of symbol (define the default height) barcode.BoundingRectangle = new Rectangle(0, 0, 254, 100 /* = 1 inch */); // now calculate optimal bitmap size for the bar code Size optimalSize = barcode.CalculateOptimalBitmapSize(null, 1, 1); // update rectangle to optimized size barcode.BoundingRectangle = new Rectangle(0, 0, optimalSize.Width, optimalSize.Height); barcode.Draw(filename, ImageType.Jpg);