我正在使用谷歌视觉API扫描条形码和qrcode。现在,我想再给用户一个方便,用户可以生成文本,网址,电话,vcard等条形码/qrcode。
所以有人知道怎么做到这一点吗?因为google商店上有很多应用程序,它们都在做同样的事情。
发布于 2016-12-30 17:52:39
发布于 2020-02-09 21:16:27
我试着用这段代码来生成Qr,它适用于我使用这段代码
public static Bitmap generateQrCode(String myCodeText) throws WriterException {
Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); // H = 30% damage
QRCodeWriter qrCodeWriter = new QRCodeWriter();
int size = 256;
BitMatrix bitMatrix= qrCodeWriter.encode(myCodeText,BarcodeFormat.QR_CODE, size, size, hintMap);
int width = bitMatrix.getWidth();
Bitmap bmp = Bitmap.createBitmap(width, width, Bitmap.Config.RGB_565);
for (int x = 0; x < width; x++) {
for (int y = 0; y < width; y++) {
bmp.setPixel(y, x, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE);
}
}
return bmp;
}试试看
https://stackoverflow.com/questions/41400421
复制相似问题