使用第三方类库:BarcodeLib.dll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 |
private
BitmapImage GenerateBarcodeBitmap( string
visitId) { BarcodeLib.Barcode barcode = new
BarcodeLib.Barcode(); barcode.Alignment = BarcodeLib.AlignmentPositions.CENTER; barcode.IncludeLabel = true ; barcode.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER; //b.RotateFlipType = RotateFlipType.; BarcodeLib.TYPE type = BarcodeLib.TYPE.CODE128; System.Drawing.Image image = barcode.Encode(type, visitId, Color.Black, Color.White, 200, 60); MemoryStream ms = new
MemoryStream(); Bitmap bmp = new
Bitmap(image); bmp.Save(ms, ImageFormat.Bmp); byte [] imgByte = new
byte [ms.Length]; ms.Position = 0; ms.Read(imgByte, 0, Convert.ToInt32(ms.Length)); System.Windows.Media.Imaging.BitmapImage bitmapImage = new
System.Windows.Media.Imaging.BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = new
MemoryStream(imgByte); bitmapImage.EndInit(); return
bitmapImage; } |
用Barcode生成条形码图片,布布扣,bubuko.com
原文:http://www.cnblogs.com/maomiyouai/p/3620452.html