It is Possible to add logo image in the middle of QR code image using android?
I have generated the QR code but now what i need is need to insert the logo image in the middle of QRcode.
Is there any way to achieve this.
Here is my QR code Generation code:
Bitmap myLogo = BitmapFactory.decodeResource(getResources(), R.drawable.image); public void onClick(View v) {
EditText qrInput = (EditText) findViewById(R.id.qrInput);
String qrInputText = qrInput.getText().toString();
Log.v(LOG_TAG, qrInputText);
//Find screen size
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
Point point = new Point();
// display.getSize(point);
int width = point.x;
int height = point.y;
int smallerDimension = width < height ? width : height;
smallerDimension = smallerDimension * 3/4;
//Encode with a QR Code image
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(qrInputText,null,Contents.Type.TEXT,BarcodeFormat.QR_CODE.toString(),smallerDimension);
try {
Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
ImageView myImage = (ImageView) findViewById(R.id.imageView1);
myImage.setImageBitmap(bitmap);
} catch (WriterException e) {
e.printStackTrace();
}
}
I don't have idea about that could someone please guide me to step forward.
Thanks in advance for the helping hearts.
This is how i implemented:
Bitmap myLogo = BitmapFactory.decodeResource(getResources(), R.drawable.image);
public void onClick(View v) {
// switch (v.getId()) {
// case R.id.button1:
EditText qrInput = (EditText) findViewById(R.id.qrInput);
String qrInputText = qrInput.getText().toString();
Log.v(LOG_TAG, qrInputText);
//Find screen size
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
Point point = new Point();
// display.getSize(point);
int width = point.x;
int height = point.y;
int smallerDimension = width < height ? width : height;
smallerDimension = smallerDimension * 3/4;
//Encode with a QR Code image
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(qrInputText,
null,
Contents.Type.TEXT,
BarcodeFormat.QR_CODE.toString(),
smallerDimension);
try {
Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
Bitmap mergeBitmaps(Bitmap bmp1; Bitmap bmp2)
{
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, 0, 0, null);
return;
}
ImageView myImage = (ImageView) findViewById(R.id.imageView1);
myImage.setImageBitmap(mergeBitmaps);
} catch (WriterException e) {
e.printStackTrace();
}