You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using ZXing.QrCode;
|
|
using ZXing;
|
|
using Steema.TeeChart.Web;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.BinManage
|
|
{
|
|
public partial class FormBarcode : Form
|
|
{
|
|
public FormBarcode()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
public FormBarcode(string barcodeStr)
|
|
{
|
|
InitializeComponent();
|
|
GenerateCode(barcodeStr);
|
|
}
|
|
/// <summary>
|
|
/// 生成条码
|
|
/// </summary>
|
|
/// <param name="barcodeStr"></param>
|
|
private void GenerateCode(string barcodeStr)
|
|
{
|
|
try
|
|
{
|
|
BarcodeWriter barcodeWriter = new BarcodeWriter()
|
|
{
|
|
Format = BarcodeFormat.QR_CODE,
|
|
Options = new QrCodeEncodingOptions
|
|
{
|
|
DisableECI = true,
|
|
CharacterSet = "UTF-8",
|
|
Width = 300,
|
|
Height = 100,
|
|
Margin = 0
|
|
}
|
|
};
|
|
|
|
//创建图片并保存为PNG格式
|
|
Bitmap img = barcodeWriter.Write(barcodeStr);//生成图片
|
|
//img.Save("E:\\12312.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
|
|
|
|
pictureBox1.Image = img;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|