Ejemplo n.º 1
0
        private void btnStartDecoding_Click(object sender, EventArgs e)
        {
            var fileName = txtBarcodeImageFile.Text;

            if (!File.Exists(fileName))
            {
                MessageBox.Show(this, String.Format("File not found: {0}", fileName), "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            if (fileName.EndsWith(".pdf", StringComparison.OrdinalIgnoreCase))
            {
                if (TryOnlyMultipleQRCodes)
                {
                    Decode(PdfSupport.GetBitmapsFromPdf(fileName), TryMultipleBarcodes, new List <BarcodeFormat> {
                        BarcodeFormat.QR_CODE
                    });
                }
                else
                {
                    Decode(PdfSupport.GetBitmapsFromPdf(fileName), TryMultipleBarcodes, null);
                }
            }
            else
            {
                using (var bitmap = (Bitmap)Bitmap.FromFile(fileName))
                {
                    if (TryOnlyMultipleQRCodes)
                    {
                        Decode(new[] { bitmap }, TryMultipleBarcodes, new List <BarcodeFormat> {
                            BarcodeFormat.QR_CODE
                        });
                    }
                    else
                    {
                        Decode(new[] { bitmap }, TryMultipleBarcodes, null);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void txtBarcodeImageFile_TextChanged(object sender, EventArgs e)
        {
            var fileName = txtBarcodeImageFile.Text;

            if (File.Exists(fileName))
            {
                if (fileName.EndsWith(".pdf", StringComparison.OrdinalIgnoreCase))
                {
                    picBarcode.Image = null;
                    foreach (var bitmap in PdfSupport.GetBitmapsFromPdf(fileName))
                    {
                        picBarcode.Image = bitmap;
                        break;
                    }
                }
                else
                {
                    picBarcode.Load(fileName);
                }
            }
        }