QRCodeDecoder decoder = new QRCodeDecoder();
Bitmap bm = new Bitmap(filepath);
qrdecode = decoder.decode(new QRCodeBitmapImage(bm));
bm.Dispose();
context.Response.Write("[{\"count\":1,\"list\":[{\"imgurl\":\"upload/" + filename + "\",\"qrtext\":\"" + qrdecode + "\"}]}]");
}
}
else
{
context.Response.Write("[{\"count\":0,\"list\":[{\"error\":\"没有上传文件\"}]}]");
}
break;
case "set":
string txt_qr =ConverToGB(context.Request["txt_qr"].ToString().Trim(), 16);
string qrEncoding = context.Request["qrEncoding"].ToString();
string Level = context.Request["Level"].ToString();
string txt_ver = context.Request["txt_ver"].ToString();
string txt_size = context.Request["txt_size"].ToString();
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
String encoding = qrEncoding;
if (encoding == "Byte")
{
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
}
else if (encoding == "AlphaNumeric")
{
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC;
}
else if (encoding == "Numeric")
{
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.NUMERIC;
}
try
{
int scale = Convert.ToInt16(txt_size);
qrCodeEncoder.QRCodeScale = scale;
}
catch (Exception ex)
{
return;
}
try
{
int version = Convert.ToInt16(txt_ver);
qrCodeEncoder.QRCodeVersion = version;
}
catch (Exception ex)
{
return;
}
string errorCorrect = Level;
if (errorCorrect == "L")
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
else if (errorCorrect == "M")
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
else if (errorCorrect == "Q")
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q;
else if (errorCorrect == "H")
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;