Exemplo n.º 1
2
 // Convert QR Code back to URL
 private void btnConvert_Click(object sender, EventArgs e)
 {
     QRCodeDecoder decoder = new QRCodeDecoder();
     MessageBox.Show(decoder.decode(new QRCodeBitmapImage(pbQR.Image as Bitmap)));
 }
Exemplo n.º 2
1
 public static string GetCodeFromPicture(Bitmap pic)
 {
     QRCodeDecoder decoder = new QRCodeDecoder();
     MessagingToolkit.QRCode.Codec.Data.QRCodeBitmapImage image = new QRCodeBitmapImage(pic);
     return decoder.Decode(image, Encoding.Unicode);
 }
Exemplo n.º 3
0
        public Dictionary <string, string> LerVariosQRCode(string caminhoPDF, string diretorio)
        {
            Dictionary <string, string> output = new Dictionary <string, string>();

            caminhos = ImageConvertor.ConvertPDFToImage(new PdfReader(caminhoPDF), diretorio, new PdfReader(caminhoPDF).NumberOfPages).ToList();
            MessagingToolkit.QRCode.Codec.QRCodeDecoder dec = new MessagingToolkit.QRCode.Codec.QRCodeDecoder();
            try
            {
                foreach (var caminho in caminhos)
                {
                    try
                    {
                        Bitmap bitmap = new Bitmap(System.Drawing.Image.FromFile(caminho));
                        output.Add(caminho, dec.decode(new MessagingToolkit.QRCode.Codec.Data.QRCodeBitmapImage(bitmap)));
                        bitmap.Dispose();
                        GC.SuppressFinalize(bitmap);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                return(output);
            }
            finally
            {
                GC.SuppressFinalize(dec);
                GC.SuppressFinalize(output);

                File.Delete(caminhoPDF);
            }
        }
Exemplo n.º 4
0
 public DecodeResult(QRCodeDecoder enclosingInstance, sbyte[] decodedBytes, int numErrors, bool correctionSucceeded)
 {
     InitBlock(enclosingInstance);
     this.decodedBytes = decodedBytes;
     this.numCorrections = numErrors;
     this.correctionSucceeded = correctionSucceeded;
 }
Exemplo n.º 5
0
 public DecodeResult(QRCodeDecoder enclosingInstance, sbyte[] decodedBytes, int numErrors, bool correctionSucceeded)
 {
     InitBlock(enclosingInstance);
     this.decodedBytes        = decodedBytes;
     this.numCorrections      = numErrors;
     this.correctionSucceeded = correctionSucceeded;
 }
Exemplo n.º 6
0
 public static Store ReadImage(Bitmap file)
 {
     using (file)
     {
         MessagingToolkit.QRCode.Codec.QRCodeDecoder decoder = new MessagingToolkit.QRCode.Codec.QRCodeDecoder();
         string res = decoder.decode(new QRCodeBitmapImage(file));
         return(JsonConvert.DeserializeObject <Store>(res));
     }
 }
Exemplo n.º 7
0
 private void decode_Qr()
 {
     QRCodeBitmapImage qbm = new QRCodeBitmapImage(de_bmp);
     QRCodeDecoder decodeer = new QRCodeDecoder();
       textBox1.Text= decodeer.Decode(qbm);
 }
Exemplo n.º 8
0
 private void InitBlock(QRCodeDecoder enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
Exemplo n.º 9
0
 public DecodeResult(QRCodeDecoder enclosingInstance, sbyte[] decodedBytes, int numCorrectionFailures)
 {
     InitBlock(enclosingInstance);
     this.decodedBytes = decodedBytes;
     this.numCorrectionFailures = numCorrectionFailures;
 }
Exemplo n.º 10
0
        /// <summary>
        /// Click on the camera. Opens a QRCode for prefiled code.
        /// </summary>
        /// <param name="sender">Button.</param>
        /// <param name="e">Nothing.</param>
        void Btn_imageClick(object sender, EventArgs e)
        {
            if (ofd_picture.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    QRCodeDecoder decoder = new QRCodeDecoder();
                    QRCodeImage img = new QRCodeBitmapImage((Bitmap)Bitmap.FromFile(ofd_picture.FileName));
                    string data = decoder.Decode(img);

                    Uri u = new Uri(data);

                    if (u.Scheme != "otpauth" || u.Host != "totp")
                    {
                        throw new Exception();
                    }

                    if (u.AbsolutePath.Length > 1)
                    {
                        txt_name.Text = System.Uri.UnescapeDataString(u.AbsolutePath.Substring(1));
                    }
                    if (u.Query.Length > 8)
                    {
                        txt_code.Text = u.Query.Substring(8);
                    }
                }
                catch
                {
                    MessageBox.Show("Error loading image",
                                    "Error while loading image. Is it a QRCode with totp data ?",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 11
0
 private void InitBlock(QRCodeDecoder enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
Exemplo n.º 12
0
 public DecodeResult(QRCodeDecoder enclosingInstance, sbyte[] decodedBytes, int numCorrectionFailures)
 {
     this.InitBlock(enclosingInstance);
     this.decodedBytes          = decodedBytes;
     this.numCorrectionFailures = numCorrectionFailures;
 }