Exemple #1
0
 public void UpdateOptions(PDF417BarcodeWriteOptions options)
 {
     foreach (ImageViewerInteractiveMode mode in _viewer.InteractiveModes)
     {
         if (mode is WriteBarcodeInteractiveMode)
         {
             WriteBarcodeInteractiveMode writeMode = (WriteBarcodeInteractiveMode)mode;
             writeMode.WriteOptions = options;
             _writeOptions          = options;
         }
     }
 }
Exemple #2
0
        private void WriteBarcodeForm_Load(object sender, System.EventArgs e)
        {
            // initialize the _viewer object
            _viewer           = new ImageViewer();
            _viewer.Dock      = DockStyle.Fill;
            _viewer.BackColor = Color.DarkGray;
            Controls.Add(_viewer);
            _viewer.BringToFront();

            // initialize the codecs object.
            _codecs = new RasterCodecs();

            try
            {
                string imagePath = Path.Combine(DemosGlobal.ImagesFolder, "license_sample_rear_blank.png");
                _viewer.Image = _codecs.Load(imagePath);
            }
            catch
            {
                _viewer.Image = RasterImage.Create(1100, 700, 24, 150, RasterColor.White);
            }

            _barcodeEngine = new BarcodeEngine();
            _writeOptions  = (PDF417BarcodeWriteOptions)_barcodeEngine.Writer.GetDefaultOptions(BarcodeSymbology.PDF417);

            //Refer to AAMVA CDS 2016 Section D.3 thru D.11.2

            //Must range from 0.0066 to 0.015 inches
            _writeOptions.XModule = 15; //0.015
            //Must >= 3
            _writeOptions.XModuleAspectRatio = 3;
            //Error level must be at least 3, 5 is recommended
            _writeOptions.ECCLevel = PDF417BarcodeECCLevel.Level5;
            //Default WidthAspectRatio is 2:1. 4:1 looks similar to ID barcodes in the wild
            _writeOptions.SymbolWidthAspectRatio = 4;
            //Default quiet zone for PDF417 is 2 * XModule


            _viewer.BeginUpdate();
            WriteBarcodeInteractiveMode writeBarcodeInteractiveMode = new WriteBarcodeInteractiveMode(_barcodeEngine, _aamvaData, _writeOptions);

            writeBarcodeInteractiveMode.IsEnabled = true;
            ImageViewerPanZoomInteractiveMode panZoomInteractiveMode = new ImageViewerPanZoomInteractiveMode();

            _viewer.InteractiveModes.Add(writeBarcodeInteractiveMode);
            _viewer.InteractiveModes.Add(panZoomInteractiveMode);
            _viewer.EndUpdate();


            UpdateMyControls();
        }