FAQ TBarCode .NET
Come posso creare un Data Matrix con 1BPP e 1200 DPI?
Come posso creare un Data Matrix con 1BPP e 1200 DPI?
Il seguente codice di esempio per C# .NET mostra come creare un TIFF con 1 bpp (B/N) e 1200 dpi.
Barcode barcode = new TECIT.TBarCode.Barcode();
//barcode.License(…)
barcode.BarcodeType = BarcodeType.DataMatrix;
barcode.Dpi = -1; // Use DPI from screen DC
barcode.SizeMode = SizeMode.FitToBoundingRectangle;
barcode.Data = "TEST 1234";
float dpi = 1200;
int nScale = 12; // 1 Dot = 12 Pixel (at 1200 dpi, this is 0.254 mm)
// Calculate bounding rectangle using a scaled module width adapted to Pixel boundaries
Size sizePx = barcode.CalculateOptimalBitmapSize(null, nScale, nScale);
barcode.BoundingRectangleF = new RectangleF(0, 0, sizePx.Width, sizePx.Height);
Bitmap myBarcode = barcode.DrawBitmap();
//myBarcode.SetResolution(dpi, dpi);
//myBarcode.Save("c:\\temp\\ExportedFile.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
Bitmap converted = myBarcode.Clone(new Rectangle(0, 0, myBarcode.Width, myBarcode.Height), System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
converted.SetResolution(dpi, dpi);
converted.Save("c:\\temp\\ExportedFile.tif", System.Drawing.Imaging.ImageFormat.Tiff);