C#二维码和条形码生成 打印处理并且可以生成Logo二维码
private Bitmap GenByZXingNet(string msg)
{
try
{
BarcodeWriter writer = new BarcodeWriter();
writer.Format = BarcodeFormat.QR_CODE;
writer.Options.Hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8");//编码问题
writer.Options.Hints.Add(EncodeHintType.ERROR_CORRECTION, ZXing.QrCode.Internal.ErrorCorrectionLevel.H);
const int codeSizeInPixels = 250; //设置图片长宽
writer.Options.Height = writer.Options.Width = codeSizeInPixels;
writer.Options.Margin = 0;//设置边框
ZXing.Common.BitMatrix bm = writer.Encode(msg);
Bitmap img = writer.Write(bm);
PicTwoImage.Image = img;
PicTwoImage1.Image = img;
PicTwoImage2.Image = img;
return img;
}
catch(Exception ex)
{
return null;
}
}
评论