0
我正在制作一个QR码生成器,使用zxing库为Android。该应用程序工作得很好。但是,我需要在生成的QR代码的中心添加徽标。我已阅读a tutorial from this web,但它并不接近我正在寻找的东西。在QR码前添加Logo
这里是我的代码示例:
private void generateQRCode_general(String data, ImageView img) throws WriterException {
com.google.zxing.MultiFormatWriter writer = new MultiFormatWriter();
String finaldata = Uri.encode(data, "utf-8");
BitMatrix bm = writer.encode(finaldata, BarcodeFormat.CODE_128, 150, 150);
Bitmap ImageBitmap = Bitmap.createBitmap(180, 40, Config.ARGB_8888);
for (int i = 0; i < 180; i++) {//width
for (int j = 0; j < 40; 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();
}
}
你可以添加一些更多的细节。也许它应该是什么样子。添加一些截图。 – mikepenz
我知道你的repu是不够的上传图片,你可以使用http://tinypic.com/添加图片,并在这里添加链接 –
看看这个项目https://github.com/skrymer/qrbuilder –