type
  TBarcodeFormat = (Aztec, Codabar, Code128, Code39, Code93,
    DataMatrix, Ean13, Ean8, Itf, Maxicode, Pdf417,
    QrCode, Rss14, RssExpanded, UpcA, UpcE, UpcEanExtension);

  TBarcodeFormats = set of TBarcodeFormat;

  TDecodeResult = record
    Text: string;
    Format: TBarcodeFormat;
    FormatName: string;
    Points: TArray<TPointF>;
    Timestamp: Int64;
    Bytes: TBytes;
    BitCount: Integer;
    ByteSegments: TArray<TBytes>;
    Country: string;
    CorrectionLevel: string;
    Extension: string;
    Price: string;
    SymbologyIdentifier: string;
    Pdf417Metadata: TPdf417Metadata;
  end;

  TDecodeResults = TArray<TDecodeResult>;

  TPdf417Metadata = record
    Addressee: string;
    Checksum: Integer;
    FileId: string;
    FileName: string;
    FileSize: Int64;
    LastSegment: Boolean;
    SegmentCount: Integer;
    SegmentIndex: Integer;
    Sender: string;
    Timestamp: Int64;
  end;

const
  AllBarcodeFormats =
  [
    TBarcodeFormat.Aztec,
    TBarcodeFormat.Codabar,
    TBarcodeFormat.Code128,
    TBarcodeFormat.Code39,
    TBarcodeFormat.Code93,
    TBarcodeFormat.DataMatrix,
    TBarcodeFormat.Ean13,
    TBarcodeFormat.Ean8,
    TBarcodeFormat.Itf,
    TBarcodeFormat.Maxicode,
    TBarcodeFormat.Pdf417,
    TBarcodeFormat.QrCode,
    TBarcodeFormat.Rss14,
    TBarcodeFormat.RssExpanded,
    TBarcodeFormat.UpcA,
    TBarcodeFormat.UpcE,
    TBarcodeFormat.UpcEanExtension
  ];

type
  TBarcodeDecoder = class
    constructor Create;

    function Decode(Bitmap: TBitmap): TDecodeResults;
    function Decode(Bitmap: TBitmap; Rect: TRect): TDecodeResults;
    function Decode(BitmapWidth, BitmapHeight: Integer; BitmapData: TJavaArray<Integer>): TDecodeResults;

    class function GetBitmapData(Bitmap: TBitmap): TJavaArray<Integer>; static;
    class function GetBitmapData(Bitmap: TBitmap; Rect: TRect): TJavaArray<Integer>; static;

    property AssumeGS1: Boolean read write default False;
    property CodabarStartEnd: Boolean read write default False;
    property Code39CheckDigit: Boolean read write default False;
    property Formats: TBarcodeFormats read write default AllBarcodeFormats;
    property Inverted: Boolean read write default False;
    property Multiple: Boolean read write default True;
    property Pure: Boolean read write default False;
    property TryHarder: Boolean read write default False;
  end;