public static void InitBarcodeReader(BarcodeReader reader, bool doublePass) { // Default options to read most barcodes reader.ImageType = BarcodeImageType.Unknown; // Both directions for 1D OneDBarcodeReadOptions oneDOptions = reader.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeReadOptions; oneDOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; GS1DatabarStackedBarcodeReadOptions gs1Options = reader.GetDefaultOptions(BarcodeSymbology.GS1DatabarStacked) as GS1DatabarStackedBarcodeReadOptions; gs1Options.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; FourStateBarcodeReadOptions fourStateOptions = reader.GetDefaultOptions(BarcodeSymbology.USPS4State) as FourStateBarcodeReadOptions; fourStateOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; PatchCodeBarcodeReadOptions patchCodeOptions = reader.GetDefaultOptions(BarcodeSymbology.PatchCode) as PatchCodeBarcodeReadOptions; patchCodeOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; PostNetPlanetBarcodeReadOptions postNetOptions = reader.GetDefaultOptions(BarcodeSymbology.PostNet) as PostNetPlanetBarcodeReadOptions; postNetOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; PharmaCodeBarcodeReadOptions pharmaCodeOptions = reader.GetDefaultOptions(BarcodeSymbology.PharmaCode) as PharmaCodeBarcodeReadOptions; pharmaCodeOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; // Double pass oneDOptions.EnableDoublePass = doublePass; DatamatrixBarcodeReadOptions dataMatrixOptions = reader.GetDefaultOptions(BarcodeSymbology.Datamatrix) as DatamatrixBarcodeReadOptions; dataMatrixOptions.EnableDoublePass = doublePass; PDF417BarcodeReadOptions pdf417Options = reader.GetDefaultOptions(BarcodeSymbology.PDF417) as PDF417BarcodeReadOptions; pdf417Options.EnableDoublePass = doublePass; MicroPDF417BarcodeReadOptions microPdf4127Options = reader.GetDefaultOptions(BarcodeSymbology.MicroPDF417) as MicroPDF417BarcodeReadOptions; microPdf4127Options.EnableDoublePass = doublePass; QRBarcodeReadOptions qrOptions = reader.GetDefaultOptions(BarcodeSymbology.QR) as QRBarcodeReadOptions; qrOptions.EnableDoublePass = doublePass; reader.ImageType = BarcodeImageType.Unknown; }
private static BarcodeReadOptions[] GetHorizontalAndVerticalReadBarcodeOptions(BarcodeReader reader) { // By default, the options read horizontal barcodes only, create an array of options capable of reading vertical barcodes // Notice, we cloned the default options in reader so we will not change the original options OneDBarcodeReadOptions oneDReadOptions = reader.GetDefaultOptions(BarcodeSymbology.UPCA).Clone() as OneDBarcodeReadOptions; oneDReadOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; FourStateBarcodeReadOptions fourStateReadOptions = reader.GetDefaultOptions(BarcodeSymbology.USPS4State).Clone() as FourStateBarcodeReadOptions; fourStateReadOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; PostNetPlanetBarcodeReadOptions postNetPlanetReadOptions = reader.GetDefaultOptions(BarcodeSymbology.PostNet).Clone() as PostNetPlanetBarcodeReadOptions; postNetPlanetReadOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; GS1DatabarStackedBarcodeReadOptions gs1StackedReadOptions = reader.GetDefaultOptions(BarcodeSymbology.GS1DatabarStacked).Clone() as GS1DatabarStackedBarcodeReadOptions; gs1StackedReadOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; PatchCodeBarcodeReadOptions patchCodeReadOptions = reader.GetDefaultOptions(BarcodeSymbology.PatchCode).Clone() as PatchCodeBarcodeReadOptions; patchCodeReadOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; PDF417BarcodeReadOptions pdf417ReadOptions = reader.GetDefaultOptions(BarcodeSymbology.PDF417).Clone() as PDF417BarcodeReadOptions; pdf417ReadOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; MicroPDF417BarcodeReadOptions microPdf417ReadOptions = reader.GetDefaultOptions(BarcodeSymbology.MicroPDF417).Clone() as MicroPDF417BarcodeReadOptions; microPdf417ReadOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical; // Even though this array will not contain all options, it should be enough to read all barcodes, since the version of ReadBarcodes we will use // will use the default options if an override is not passed BarcodeReadOptions[] readOptions = { oneDReadOptions, fourStateReadOptions, postNetPlanetReadOptions, gs1StackedReadOptions, patchCodeReadOptions, pdf417ReadOptions, microPdf417ReadOptions }; return(readOptions); }