I have this method that reads the bitmap image to decode a qr code in a certain area in the document ( looking into four corners for qr code) Because of how i have my code it is always hitting the error message which i know that it cannot find the bitmap but i want to take this error and translate in a way that executes my remaining code which is to rotate the document and look again for the qr bitmap image.
Code:
Bitmap[] corners = new Bitmap[] { bandImg1, bandImg2, bandImg3, bandImg4 };
string QRinfo = "";
for (int i = 0; i < corners.Length; ++i)
{
string tempQRinfo = Process(corners[i]);
if (tempQRinfo == null)
{
QRinfo = tempQRinfo;
switch (i)
{
case 0: break; //upper left
case 1: fullImg.RotateFlip(RotateFlipType.Rotate270FlipNone); break;
case 2: fullImg.RotateFlip(RotateFlipType.Rotate90FlipNone); break;
case 3: fullImg.RotateFlip(RotateFlipType.Rotate180FlipNone); break;
}
break;
}
}
Process method that is causing the error when not finding the image.
public string Process(Bitmap bitmap)
{
var reader = new com.google.zxing.qrcode.QRCodeReader();
try
{
LuminanceSource source = new RGBLuminanceSource(bitmap, bitmap.Width, bitmap.Height);
var binarizer = new HybridBinarizer(source);
var binBitmap = new BinaryBitmap(binarizer);
return reader.decode(binBitmap).Text;
}
catch (Exception e)
{
return e.Message;
}
}
HELP WITH: I want to translate the error message to have the document search in all four corners where it has the qr code and then rotate as shown above.