FAQ TBarCode .NET
DrawBitmap Creates a Very Small Font Size
DrawBitmap Creates a Very Small Font Size
If you want to create a high resolution bitmap (DPI >= 300), you may encounter a very small font size of the HRT in the resulting bitmap.
The following C# sample code demonstrates the influence of the screen DC (96 dpi) when you use DrawBitmap(). You can solve this issue either by using the Draw() image export function or DrawBitmap() with IgnoreDPIFromDC enabled.
Barcode code128 = new Barcode(); code128.BarcodeType = BarcodeType.Code128; code128.Data = "HELLO"; code128.Dpi = 600; code128.BoundingRectangle = new Rectangle(0, 0, code128.CalculateNumberOfModules() * 6, 600); // one module = 6 Pixel code128.Draw(@"C:\temp\Draw-OK.bmp", ImageType.Bmp); // HRT is scaled correctly Bitmap test1 = code128.DrawBitmap(); test1.Save(@"C:\temp\DrawBitmap-NOK.bmp"); // HRT is very small (scaled to 96 dpi screen resolution instead of 600) code128.IgnoreDpiFromDC = true; Bitmap test2 = code128.DrawBitmap(); test2.Save(@"C:\temp\DrawBitmap-OK.bmp"); // HRT is scaled to 600 dpi (Screen DC is ignored).