【发布时间】:2014-04-17 18:35:00
【问题描述】:
使用zxing生成二维码的代码是---
它需要字符串数据和imageview 这很好用
private void generateQRCode_general(String data, ImageView img)throws WriterException {
com.google.zxing.Writer writer = new QRCodeWriter();
String finaldata = Uri.encode(data, "utf-8");
BitMatrix bm = writer.encode(finaldata, BarcodeFormat.QR_CODE,150, 150);
Bitmap ImageBitmap = Bitmap.createBitmap(150, 150,Config.ARGB_8888);
for (int i = 0; i < 150; i++) {//width
for (int j = 0; j < 150; j++) {//height
ImageBitmap.setPixel(i, j, bm.get(i, j) ? Color.BLACK: Color.WHITE);
}
}
if (ImageBitmap != null) {
qrcode.setImageBitmap(ImageBitmap);
} else {
Toast.makeText(getApplicationContext(), getResources().getString(R.string.userInputError),
Toast.LENGTH_SHORT).show();
}
}
现在我的问题是,如何使用同一个库获取bar code。我看到了一些与bar codes 相关的文件,但我不知道该怎么做。
因为我想在应用程序中生成bar code,而不是调用任何web service。由于我已经在使用 zxing,所以没有必要包含 itext 和 barbecue jars
【问题讨论】: