Spelt / ZXing.Delphi

ZXing Barcode Scanning object Pascal Library for Delphi VCL and Delphi Firemonkey
Apache License 2.0
471 stars 206 forks source link

How to read only 1D barcodes? #111

Closed rojillo1 closed 3 years ago

rojillo1 commented 3 years ago

Is there any way to instruct it to read only 1D codes?

Specifically, these would be the codes that you should only read: UPC-A, UPC-E, EAN-8, EAN-13

Greetings.

Spelt commented 3 years ago

Yes you can do that with something like:

var listFormats := TList.Create();

'add your formats to the listFormats here' like : listFormats.Add(TBarcodeFormat.UPC_E);

var hints: TDictionary<TDecodeHintType, TObject>; hints := TDictionary<TDecodeHintType, TObject>.Create(); Hints.Add(ZXing.DecodeHintType.POSSIBLE_FORMATS, listFormats);

ScanManager := TScanManager.Create(TBarcodeFormat.UPC_A, Hints);

Op ma 19 okt. 2020 om 20:15 schreef rojillo1 notifications@github.com:

Is there any way to instruct it to read only 1D codes?

Specifically, these would be the codes that you should only read: UPC-A, UPC-E, EAN-8, EAN-13

Greetings.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Spelt/ZXing.Delphi/issues/111, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAS3VLMSTIBZCHAPO42ZZ3SLR625ANCNFSM4SWPWROA .

rojillo1 commented 3 years ago

Thanks spelt, it works perfectly.

Greetings.

rojillo1 commented 3 years ago

I update the theme, with version 10.3.3 it works perfectly.

Today I have updated to version 10.4.1 and when I try to capture a barcode the image freezes and abruptly ends the program, I use this code:

var listFormats := TList<TBarcodeFormat>.Create();

'add your formats to the listFormats here' like :
listFormats.Add(TBarcodeFormat.EAN_8);
listFormats.Add(TBarcodeFormat.EAN_13);
listFormats.Add(TBarcodeFormat.UPC_A;
listFormats.Add(TBarcodeFormat.UPC_E);
listFormats.Add(TBarcodeFormat.UPC_EAN_EXTENSION);

var hints: TDictionary<TDecodeHintType, TObject>;
hints := TDictionary<TDecodeHintType, TObject>.Create();
Hints.Add(ZXing.DecodeHintType.POSSIBLE_FORMATS, listFormats);

ScanManager: = TScanManager.Create (TBarcodeFormat.auto, Hints);

Instead the program works correctly with this code:

ScanManager: = TScanManager.Create (TBarcodeFormat.auto, nil);

Greetings.