Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 QR code.

Is there any way to achieve this.

Here is my QR code with Logo Generation code:

>private String LOG_TAG = "GenerateQRCode";
private Bitmap myLogo, bitmap, bitMerged;

public void onClick(View v) {

EditText qrInput = (EditText) findViewById(R.id.qrInput);
String qrInputText = qrInput.getText().toString();
Log.v(LOG_TAG, qrInputText);
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 = qrCodeEncoder.encodeAsBitmap();

myLogo = BitmapFactory.decodeResource(getResources(), R.drawable.image);

bitMerged = mergeBitmaps(bitmap, myLogo);

ImageView myImage = (ImageView) findViewById(R.id.imageView1);

myImage.setImageBitmap(bitMerged);

} catch (WriterException e) {
e.printStackTrace();
}
}
public static 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 bmOverlay;
}
}

I don't have idea about that could someone please guide me to clear this issue..

Thanks in advance for the helping hearts.
Posted
Updated 22-May-14 19:31pm
v3
Comments
Member 10556609 22-May-14 8:38am    
Will You please help me anyone..Thanks in advance

 
Share this answer
 
Comments
Member 10556609 22-May-14 8:14am    
Thanks for ur response sir. But i need android coding... Ur sol is related to asp.net
What you need to do is to merge the two bitmaps. So you can use Canvas[^]

1. create a Canvas, and specify a bitmap (the QR code bitmap) for it.
setBitmap(Bitmap bitmap)

2. draw the logo onto the QR code bitmap.
public void drawBitmap (Bitmap bitmap, Rect src, RectF dst, Paint paint)
 
Share this answer
 
Comments
Member 10556609 23-May-14 1:36am    
Hai,Thanks for ur Response..My qr image with logo coding is updated above..as u said.. But the image is not mapping in imageview..Please Verify my coding and tell me the solution..Thanks in advance.I hope u definetely cleared my issue

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900