FAQ TBarCode .NET
Comment créer un Data Matrix en 1BPP et 1200 PPP ?
Comment créer un Data Matrix en 1BPP et 1200 PPP ?
L'exemple de code suivant en C# .NET vous montre comment créer un TIFF en 1 bpp (N/B) et 1200 ppp.
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);