c# 二维码识别内容

2025-04-03 17:08:50
推荐回答(2个)
回答(1):

private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
MultiFormatReader mutiReader = new com.google.zxing.MultiFormatReader();
Bitmap img = (Bitmap)Bitmap.FromFile(op.ShowDialog().ToString());
if (img == null)
return;
LuminanceSource ls = new RGBLuminanceSource(img, img.Width, img.Height);
BinaryBitmap bb = new BinaryBitmap(new com.google.zxing.common.HybridBinarizer(ls));

Result r = mutiReader.decode(bb);
txtMsg.Text = r.Text;
}
自己看吧,我就不解释了

回答(2):

简单的就是将输入光标定位到TextBox框中,然后扫描枪扫二维码,读出的东西会自动填到TextBox中