使用Barcode Professional for WPF条码控件创建一个TIFF条码图片是一个非常简单的任务,仅需要几句代码就可以实现,下面分别列举了多种创建和保存TIFF条码图片的事例,开发人员可以从
控件中国网下载该产品的试用版进行测试,需要的环境是Microsoft .NET Framework 3.0 以上。
1.根据给定的分辨率创建和保存TIFF条码图片
private void SaveBarcode()
{
//Create a BarcodeBuilder object
Neodynamic.WPF.BarcodeBuilder bc = new Neodynamic.WPF.BarcodeBuilder();
//Set the barcode symbology to Code 128
bc.Symbology = Neodynamic.WPF.Symbology.Code128;
//Set the value to encode
bc.Code = "1234567890";
//Barcode dimensions settings
bc.BarcodeUnit = Neodynamic.WPF.BarcodeUnit.Inch;
bc.BarHeight = 1.5d;
bc.BarWidth = 0.02d;
//Output image settings
bc.ImageSettings.Dpi = 300;
bc.ImageSettings.ImageFormat = Neodynamic.WPF.ImageFormat.Tiff;
//Save the TIFF barcode image on disk
bc.Save(@"C:\barcode128.tif");
}
2.怎么根据给定的分辨率创建黑白的TIFF条码图片
private void SaveBarcode()
{
//Create a BarcodeBuilder object
Neodynamic.WPF.BarcodeBuilder bc = new Neodynamic.WPF.BarcodeBuilder();
//Set the barcode symbology to Code 128
bc.Symbology = Neodynamic.WPF.Symbology.Code128;
//Set the value to encode
bc.Code = "1234567890";
//Barcode dimensions settings
bc.BarcodeUnit = Neodynamic.WPF.BarcodeUnit.Inch;
bc.BarHeight = 1.5d;
bc.BarWidth = 0.02d;
//Output image settings
bc.ImageSettings.Dpi = 300;
bc.ImageSettings.ImageFormat = Neodynamic.WPF.ImageFormat.Tiff;
//Set monochrome
bc.ImageSettings.PixelFormat = System.Windows.Media.PixelFormats.BlackWhite;
//Save the TIFF barcode image on disk
bc.Save(@"C:\barcode128_BW.tif");
}
3.怎么根据给定的分辨率创建彩色的TIFF条码图片
private void SaveBarcode()
{
//Create a BarcodeBuilder object
Neodynamic.WPF.BarcodeBuilder bc = new Neodynamic.WPF.BarcodeBuilder();
//Set the barcode symbology to Code 128
bc.Symbology = Neodynamic.WPF.Symbology.Code128;
//Set the value to encode
bc.Code = "1234567890";
//Barcode dimensions settings
bc.BarcodeUnit = Neodynamic.WPF.BarcodeUnit.Inch;
bc.BarHeight = 1.5d;
bc.BarWidth = 0.02d;
//Output image settings
bc.ImageSettings.Dpi = 300;
bc.ImageSettings.ImageFormat = Neodynamic.WPF.ImageFormat.Tiff;
//Set CMYK
bc.ImageSettings.PixelFormat = System.Windows.Media.PixelFormats.Cmyk32;
//Save the TIFF barcode image on disk
bc.Save(@"C:\barcode128_CMYK.tif");
}