|
|
|
@ -20,13 +20,14 @@ class GeneratedBindings {
|
|
|
|
|
: _lookup = lookup; |
|
|
|
|
|
|
|
|
|
/// @brief Enables or disables the logging of the library. |
|
|
|
|
/// @param enable Whether to enable or disable the logging. |
|
|
|
|
/// |
|
|
|
|
/// @param enabled |
|
|
|
|
void setLogEnabled( |
|
|
|
|
int enabled, |
|
|
|
|
int enable, |
|
|
|
|
) { |
|
|
|
|
return _setLogEnabled( |
|
|
|
|
enabled, |
|
|
|
|
enable, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -47,15 +48,16 @@ class GeneratedBindings {
|
|
|
|
|
late final _version = |
|
|
|
|
_versionPtr.asFunction<ffi.Pointer<ffi.Char> Function()>(); |
|
|
|
|
|
|
|
|
|
/// @brief Reads barcode from image. |
|
|
|
|
/// @brief Read barcode from image bytes. |
|
|
|
|
/// @param bytes Image bytes. |
|
|
|
|
/// @param format The format of the barcode |
|
|
|
|
/// @param width Image width. |
|
|
|
|
/// @param height Image height. |
|
|
|
|
/// @param format Specify a set of BarcodeFormats that should be searched for. |
|
|
|
|
/// @param width Image width in pixels. |
|
|
|
|
/// @param height Image height in pixels. |
|
|
|
|
/// @param cropWidth Crop width. |
|
|
|
|
/// @param cropHeight Crop height. |
|
|
|
|
/// @param logEnabled Log enabled. |
|
|
|
|
/// @return Barcode result. |
|
|
|
|
/// @param tryHarder Spend more time to try to find a barcode; optimize for accuracy, not speed. |
|
|
|
|
/// @param tryRotate Also try detecting code in 90, 180 and 270 degree rotated images. |
|
|
|
|
/// @return The barcode result. |
|
|
|
|
CodeResult readBarcode( |
|
|
|
|
ffi.Pointer<ffi.Char> bytes, |
|
|
|
|
int format, |
|
|
|
@ -63,6 +65,8 @@ class GeneratedBindings {
|
|
|
|
|
int height, |
|
|
|
|
int cropWidth, |
|
|
|
|
int cropHeight, |
|
|
|
|
int tryHarder, |
|
|
|
|
int tryRotate, |
|
|
|
|
) { |
|
|
|
|
return _readBarcode( |
|
|
|
|
bytes, |
|
|
|
@ -71,25 +75,29 @@ class GeneratedBindings {
|
|
|
|
|
height, |
|
|
|
|
cropWidth, |
|
|
|
|
cropHeight, |
|
|
|
|
tryHarder, |
|
|
|
|
tryRotate, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
late final _readBarcodePtr = _lookup< |
|
|
|
|
ffi.NativeFunction< |
|
|
|
|
CodeResult Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int, |
|
|
|
|
ffi.Int, ffi.Int)>>('readBarcode'); |
|
|
|
|
ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcode'); |
|
|
|
|
late final _readBarcode = _readBarcodePtr.asFunction< |
|
|
|
|
CodeResult Function(ffi.Pointer<ffi.Char>, int, int, int, int, int)>(); |
|
|
|
|
CodeResult Function( |
|
|
|
|
ffi.Pointer<ffi.Char>, int, int, int, int, int, int, int)>(); |
|
|
|
|
|
|
|
|
|
/// @brief Reads barcodes from image. |
|
|
|
|
/// @brief Read barcodes from image bytes. |
|
|
|
|
/// @param bytes Image bytes. |
|
|
|
|
/// @param format The format of the barcode |
|
|
|
|
/// @param width Image width. |
|
|
|
|
/// @param height Image height. |
|
|
|
|
/// @param format Specify a set of BarcodeFormats that should be searched for. |
|
|
|
|
/// @param width Image width in pixels. |
|
|
|
|
/// @param height Image height in pixels. |
|
|
|
|
/// @param cropWidth Crop width. |
|
|
|
|
/// @param cropHeight Crop height. |
|
|
|
|
/// @param logEnabled Log enabled. |
|
|
|
|
/// @return Barcode results. |
|
|
|
|
/// @param tryHarder Spend more time to try to find a barcode, optimize for accuracy, not speed. |
|
|
|
|
/// @param tryRotate Also try detecting code in 90, 180 and 270 degree rotated images. |
|
|
|
|
/// @return The barcode results. |
|
|
|
|
CodeResults readBarcodes( |
|
|
|
|
ffi.Pointer<ffi.Char> bytes, |
|
|
|
|
int format, |
|
|
|
@ -97,6 +105,8 @@ class GeneratedBindings {
|
|
|
|
|
int height, |
|
|
|
|
int cropWidth, |
|
|
|
|
int cropHeight, |
|
|
|
|
int tryHarder, |
|
|
|
|
int tryRotate, |
|
|
|
|
) { |
|
|
|
|
return _readBarcodes( |
|
|
|
|
bytes, |
|
|
|
@ -105,23 +115,25 @@ class GeneratedBindings {
|
|
|
|
|
height, |
|
|
|
|
cropWidth, |
|
|
|
|
cropHeight, |
|
|
|
|
tryHarder, |
|
|
|
|
tryRotate, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
late final _readBarcodesPtr = _lookup< |
|
|
|
|
ffi.NativeFunction< |
|
|
|
|
CodeResults Function(ffi.Pointer<ffi.Char>, ffi.Int, ffi.Int, ffi.Int, |
|
|
|
|
ffi.Int, ffi.Int)>>('readBarcodes'); |
|
|
|
|
ffi.Int, ffi.Int, ffi.Int, ffi.Int)>>('readBarcodes'); |
|
|
|
|
late final _readBarcodes = _readBarcodesPtr.asFunction< |
|
|
|
|
CodeResults Function(ffi.Pointer<ffi.Char>, int, int, int, int, int)>(); |
|
|
|
|
CodeResults Function( |
|
|
|
|
ffi.Pointer<ffi.Char>, int, int, int, int, int, int, int)>(); |
|
|
|
|
|
|
|
|
|
/// @brief Encode a string into a barcode |
|
|
|
|
/// @param contents The string to encode |
|
|
|
|
/// @param width The width of the barcode |
|
|
|
|
/// @param height The height of the barcode |
|
|
|
|
/// @param width The width of the barcode in pixels. |
|
|
|
|
/// @param height The height of the barcode in pixels. |
|
|
|
|
/// @param format The format of the barcode |
|
|
|
|
/// @param margin The margin of the barcode |
|
|
|
|
/// @param logEnabled Log enabled. |
|
|
|
|
/// @param eccLevel The error correction level of the barcode. Used for Aztec, PDF417, and QRCode only, [0-8]. |
|
|
|
|
/// @return The barcode data |
|
|
|
|
EncodeResult encodeBarcode( |
|
|
|
@ -150,6 +162,7 @@ class GeneratedBindings {
|
|
|
|
|
EncodeResult Function(ffi.Pointer<ffi.Char>, int, int, int, int, int)>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// @brief Format Enumerates barcode formats known to this package. |
|
|
|
|
abstract class Format { |
|
|
|
|
/// < Used as a return value if no valid barcode has been detected |
|
|
|
|
static const int None = 0; |
|
|
|
@ -206,64 +219,88 @@ abstract class Format {
|
|
|
|
|
static const int Any = 65535; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// @brief Pos is a position of a barcode in a image. |
|
|
|
|
class Pos extends ffi.Struct { |
|
|
|
|
/// < x coordinate of top left corner of barcode |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int topLeftX; |
|
|
|
|
|
|
|
|
|
/// < y coordinate of top left corner of barcode |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int topLeftY; |
|
|
|
|
|
|
|
|
|
/// < x coordinate of top right corner of barcode |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int topRightX; |
|
|
|
|
|
|
|
|
|
/// < y coordinate of top right corner of barcode |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int topRightY; |
|
|
|
|
|
|
|
|
|
/// < x coordinate of bottom left corner of barcode |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int bottomLeftX; |
|
|
|
|
|
|
|
|
|
/// < y coordinate of bottom left corner of barcode |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int bottomLeftY; |
|
|
|
|
|
|
|
|
|
/// < x coordinate of bottom right corner of barcode |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int bottomRightX; |
|
|
|
|
|
|
|
|
|
/// < y coordinate of bottom right corner of barcode |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int bottomRightY; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// @brief The CodeResult class encapsulates the result of decoding a barcode within an image. |
|
|
|
|
class CodeResult extends ffi.Struct { |
|
|
|
|
/// < Whether the barcode was successfully decoded |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int isValid; |
|
|
|
|
|
|
|
|
|
/// < The decoded text |
|
|
|
|
external ffi.Pointer<ffi.Char> text; |
|
|
|
|
|
|
|
|
|
/// < The format of the barcode |
|
|
|
|
@ffi.Int32() |
|
|
|
|
external int format; |
|
|
|
|
|
|
|
|
|
/// < The position of the barcode within the image |
|
|
|
|
external ffi.Pointer<Pos> pos; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// @brief The CodeResults class encapsulates the result of decoding multiple barcodes within an image. |
|
|
|
|
class CodeResults extends ffi.Struct { |
|
|
|
|
/// < The number of barcodes detected |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int count; |
|
|
|
|
|
|
|
|
|
/// < The results of the barcode decoding |
|
|
|
|
external ffi.Pointer<CodeResult> results; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// @brief EncodeResult encapsulates the result of encoding a barcode. |
|
|
|
|
class EncodeResult extends ffi.Struct { |
|
|
|
|
/// < Whether the barcode was successfully encoded |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int isValid; |
|
|
|
|
|
|
|
|
|
/// < The encoded text |
|
|
|
|
external ffi.Pointer<ffi.Char> text; |
|
|
|
|
|
|
|
|
|
/// < The format of the barcode |
|
|
|
|
@ffi.Int32() |
|
|
|
|
external int format; |
|
|
|
|
|
|
|
|
|
/// < The encoded data |
|
|
|
|
external ffi.Pointer<ffi.UnsignedInt> data; |
|
|
|
|
|
|
|
|
|
/// < The length of the encoded data |
|
|
|
|
@ffi.Int() |
|
|
|
|
external int length; |
|
|
|
|
|
|
|
|
|
/// < The error message |
|
|
|
|
external ffi.Pointer<ffi.Char> error; |
|
|
|
|
} |
|
|
|
|