Earlier I had posted a tip regarding detecting the QR in an Image. After detecting we had also fetched the QR Image as BitMatrix object. BitMatrix is just a class in ZXing library which represents an image in 2D matrix of bits form.
I think to understand this current tip you must go through a previous tip of mine on how to detect QR code using Zing library So I am assuming now you are familiar with ZXing library,QR code. For this tip I assume my input is an object of BitMatrix class which is representing an QR(2D bar code) image.
Our aim is to decode this QR image and need to get hidden information under QR.
Now we proceed towards the steps of decoding the QR. There are three very very simple steps to do this:-
Step 1: There is a class in ZXing library named “Decoder”. First create an instance of Decoder class.
Decoder decoder = new Decoder();
Step 2: Now we need to call “decode()” method of Detector class by passing the BitMatrix object which is representing QR image.
DecoderResult decoderResult = decoder.decode(QRImage);// QRImage is name of an object of BitMatrix representing QR image
It returns an object of DecoderResult class (A class of ZXing library).
Step 3: For the last step just call "getText()" method of DecoderResult like this:
String QRString = decoderResult.getText(); // here we have some decoded QR data
It returns you hidden data from QR image in String form. This data must be encrypted.
Now according to your encryption/decryption algorithm you need to decrypt this encrypted data.
So thats the way to decode the QR code using ZXing library. ZXing library is very very strong in itself. You just need to know which method to call.
So I am done now. Hope it is helpful for you