此问题参考API文档链接,http://www.blackberry.com/developers/docs/7.0.0api/net/rim/device/api/barcodelib/BarcodeBitmap.html
他们指定旧方法
public static Bitmap createBitmap(ByteMatrix byteMatrix,
int maxBitmapSizeInPixels)
已弃用。
但通过使用新方法,
public static Bitmap createBitmap(ByteMatrix byteMatrix)
他们还没有指定一种方法来指定Multiformatwriter中QR码的纠错级别。我也找不到方法,浏览各种成员功能。有人试过这个吗?
谢谢你的帮助。
这是我的代码,我已经用手机检查过了,纠错级别是根据我的手机正确设置的。
Hashtable hints = new Hashtable();
switch (comboBox1.Text)
{
case "L":
hints.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
break;
case "Q":
hints.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.Q);
break;
case "H":
hints.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
break;
default:
hints.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
break;
}
MultiFormatWriter mw = new MultiFormatWriter();
ByteMatrix bm = mw.encode(data, BarcodeFormat.QR_CODE, size, size, hints);
Bitmap img = bm.ToBitmap();
pictureBox1.Image = img;
编码时,可以传入提示
Map<EncodeHintType, Object> hints = new Hastable<EncodeHintType, Object>();
将纠错设置添加到提示中(例如,添加到M级)
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
ZXing默认使用错误校正级别L(最低,意味着即使在最大7%的损坏后,二维码仍然可读)
刚刚查看了文档。
它说要将createBitmap(ByteMatrix byteMatrix)
与MultiFormatWriter
结合使用。它具有方法encode(String contents, BarcodeFormat format, int width, int height, Hashtable hints)
,您可以在其中指定宽度、高度和错误级别。
要指定错误级别,请使用值new Integer(level)
设置提示哈希表关键字EncodeHintType.ERROR_CORRECTION
。
不幸的是,我没有找到这里描述的这些值的任何常量。但你可能可以在axing资源中找到它。