I am creating an app which will be able to scan QR code and create QR code. The scanning part is done and its working fine. But when I try to create the QR code and show it in an ImageView the QR code created is not containing correct text. I am using ZXING library.
Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<>();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
QRCodeWriter qrCodeEncoder = new QRCodeWriter();
BitMatrix bitMatrix = qrCodeEncoder.encode(myText, BarcodeFormat.QR_CODE,
200, 200, hintMap);
height = bitMatrix.getHeight();
width = bitMatrix.getWidth();
final Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
for (x = 0; x < width; x++){
bmp.setPixel(x, y, bitMatrix.get(x,y) ? Color.BLACK : Color.WHITE);
}
ImageView myImage = (ImageView) findViewById(R.id.qr_code);
myImage.setImageBitmap(bmp);