Generation de QR CODE en rentrant des parametres
Salut la famille,
je fais une application qui dois genere un qr code avec plusieurs informations,
au scanne le client dois pas voir d'autres informations :
Code:
1 2 3 4 5 6 7 8 9
| try {
bitmap = TextToImageEncode(montant + fi + Md5 + idCompte);
imageVie.setImageBitmap(bitmap);
} catch (WriterException e) {
e.printStackTrace();
} |
Mes informations sont : montant + fi + Md5 + idCompte,
et jeux veux rendre invisible : fi + Md5 + idCompte aux yeux du client
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Bitmap TextToImageEncode(String Value) throws WriterException {
BitMatrix bitMatrix;
try {
bitMatrix = new MultiFormatWriter().encode(
Value,
BarcodeFormat.DATA_MATRIX.QR_CODE,
QRcodeWidth, QRcodeWidth, null
);
} catch (IllegalArgumentException Illegalargumentexception) {
return null;
}
int bitMatrixWidth = bitMatrix.getWidth();
int bitMatrixHeight = bitMatrix.getHeight();
int[] pixels = new int[bitMatrixWidth * bitMatrixHeight];
for (int y = 0; y < bitMatrixHeight; y++) {
int offset = y * bitMatrixWidth;
for (int x = 0; x < bitMatrixWidth; x++) {
pixels[offset + x] = bitMatrix.get(x, y) ?
getResources().getColor(R.color.QRCodeBlackColor):getResources().getColor(R.color.QRCodeWhiteColor);
}
}
Bitmap bitmap = Bitmap.createBitmap(bitMatrixWidth, bitMatrixHeight, Bitmap.Config.ARGB_4444);
bitmap.setPixels(pixels, 0, 500, 0, 0, bitMatrixWidth, bitMatrixHeight);
return bitmap;
} |
Aidez-moi et si quelqu'un a un autre code plus mieux et adapter que ca qu'il me fasse part de ça !!!
Merci