0

I am having trouble rotating a scanned document that already has a qrcode on it. I am checking for the qr code but when the code is upside down - i am having trouble flipping the page and trying to read for a qr code again. and i get this error message:

exception of type 'com.google.zxing.readerexception' was thrown

using (var fullImg = new Bitmap(workGif))
                {
                    var halfW = fullImg.Width/2;
                    var halfH = fullImg.Height / 2;
                    var bandImg = fullImg.Clone(new System.Drawing.Rectangle(0, 0, halfW, halfH), fullImg.PixelFormat);


                    if (Process(bandImg) == null)
                    {
                        page.Rotate = (page.Rotate + 180) % 360;
                    }
                    string QRinfo = Process(bandImg);
                    MessageBox.Show(QRinfo);
                    string[] qcode = QRinfo.Split('/');
                    string gid = qcode[qcode.Count() - 1];
                    Guid pgGuid = new Guid(gid);

                    MessageBox.Show(QRinfo);

                    var ar = dc.Assessments.FirstOrDefault(c => c.ID == pgGuid);
                    if (ar != null)
                    {
                        var p = inputDocument.Pages[pg];
                        string opdName = FILESTORELOCATION + pgGuid.ToString() + ".pdf";
                        PdfDocument opd = new PdfDocument(opdName);
                        opd.Pages.Add(p);
                        opd.Close();

                        ar.StoragePath = opdName;
                        ar.LastUploadedDT = DateTime.UtcNow;
                        ar.UploadedByUserID = uploadingUser;
                        dc.SubmitChanges();
                    }

                }

this is my process for decoding qr:

 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;
        }
    }
Masriyah
  • 2,445
  • 11
  • 49
  • 91

0 Answers0