1
我已经将一个字符串编码为QR位图。图片变成这样:Android QR位图需要帮助删除保证金
我需要做什么改变,使周围有没有QR空格?我尝试阅读有关MultiFormatWriter()和setPixels()的文档,但无法找到它错误的地方。 这里是代码:
Bitmap encodeAsBitmap(String str) throws WriterException {
BitMatrix result;
try {
result = new MultiFormatWriter().encode(str,
BarcodeFormat.QR_CODE, 500, 500, null);
} catch (IllegalArgumentException iae) {
return null;
}
int w = result.getWidth();
int h = result.getHeight();
int[] pixels = new int [w * h];
for (int i = 0; i < h; i++) {
int offset = i * w;
for (int j = 0; j < w; j++) {
pixels[offset + j] = result.get(i, j) ? BLACK : WHITE;
}
}
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, 500, 0, 0, w, h);
return bitmap;
}
它仍然具有输出边缘图像:( – Toeffen
我更新的代码 –
更新给出了ImageView的宽度和str.length()的高度,它使。 ImageView不可见,但是这是很好的方向,我们可能需要结果的长度(也许是?) – Toeffen