"I want to display the image on screen." After scanning the QR code I need to show that as image in my application how to go about it.
I have tried this but not getting output
BarcodeFormat barcodeFormat = BarcodeFormat.QR_CODE;
int width0 = 500;
int height0 = 500;
int colorBack = 0xFF000000;
int colorFront = 0xFFFFFFFF;
QRCodeWriter writer = new QRCodeWriter();
try
{
Hashtable<EncodeHintType, Object> hint = new Hashtable<EncodeHintType,Object>(2);
hint.put(EncodeHintType.CHARACTER_SET, "UTF-8");
ByteMatrix bitMatrix = writer.encode(fName, barcodeFormat, width0, height0, hint);
int width = bitMatrix.getWidth();
int height = bitMatrix.getHeight();
int[] pixels = new int[width * height];
for (int y = 0; y < height; y++)
{
int offset = y * width;
for (int x = 0; x < width; x++)
{
// if (bitMatrix.get(x, y))
pixels[offset + x] = colorBack;
//else
//pixels[offset + x] = colorFront;
}
}
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
ImageView imageview = (ImageView)findViewById(R.id.imageView1);
imageview.setImageBitmap(bitmap);
} catch (WriterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}