Browse Source

minor improvements

pull/98/head
Khoren Markosyan 2 years ago
parent
commit
8fd5e0dbd9
  1. 26
      example/pubspec.lock
  2. 63
      src/native_zxing.cpp
  3. 3
      src/native_zxing.h
  4. 2
      src/zxing
  5. 2
      zxscanner/lib/pages/home_page.dart
  6. 94
      zxscanner/pubspec.lock
  7. 2
      zxscanner/pubspec.yaml

26
example/pubspec.lock

@ -13,10 +13,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: archive name: archive
sha256: d6347d54a2d8028e0437e3c099f66fdb8ae02c4720c1e7534c9f24c10351f85d sha256: "0c8368c9b3f0abbc193b9d6133649a614204b528982bebc7026372d61677ce3a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.3.6" version: "3.3.7"
args: args:
dependency: transitive dependency: transitive
description: description:
@ -45,10 +45,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: camera name: camera
sha256: ad1c53c554a2f3e5708f3b01eb738d60b902bb61f7f4ad420c65c715e65a7379 sha256: "7afc256902062cab191540c09908b98bc71e93d5e20b6486dbee51aa7731e9b2"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.10.3+2" version: "0.10.4"
camera_android: camera_android:
dependency: transitive dependency: transitive
description: description:
@ -133,10 +133,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: conventional_commit name: conventional_commit
sha256: "8eee25c315cf1946215d02d598402ca75cfee8a8ab482f3fac34cb0717323afa" sha256: dec15ad1118f029c618651a4359eb9135d8b88f761aa24e4016d061cd45948f2
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.0" version: "0.6.0+1"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@ -222,7 +222,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "1.1.1" version: "1.1.2"
glob: glob:
dependency: transitive dependency: transitive
description: description:
@ -267,10 +267,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: image_picker name: image_picker
sha256: cb25f04595a88450970dbe727243ba8cd21b6f7e0d7d1fc5b789fc6f52e95494 sha256: "8b0efbf350ba4f2be1531d629396a994983d0c02f4a82a128aed84d954b90cfa"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.8.7+1" version: "0.8.7+2"
image_picker_android: image_picker_android:
dependency: transitive dependency: transitive
description: description:
@ -291,10 +291,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: image_picker_ios name: image_picker_ios
sha256: d4cb8ab04f770dab9d04c7959e5f6d22e8c5280343d425f9344f93832cf58445 sha256: a1546ff5861fc15812953d4733b520c3d371cec3d2859a001ff04c46c4d81883
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.8.7+2" version: "0.8.7+3"
image_picker_platform_interface: image_picker_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -355,10 +355,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: melos name: melos
sha256: cd8e7db0250ee822c5354a8214afc751b6c1c41aadfbbef927456d509d953244 sha256: "993ac467e7a36bd832a6cdabbe18a0487c30bc52b5cca14e476a824679ebdce0"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.0" version: "3.0.1"
meta: meta:
dependency: transitive dependency: transitive
description: description:

63
src/native_zxing.cpp

@ -14,6 +14,35 @@ using namespace std;
extern "C" extern "C"
{ {
void resultToCodeResult(struct CodeResult *code, Result result)
{
string text = result.text();
code->text = new char[text.length() + 1];
strcpy(code->text, text.c_str());
code->isValid = result.isValid();
string error = result.error().msg();
code->error = new char[error.length() + 1];
strcpy(code->error, error.c_str());
code->format = static_cast<int>(result.format());
// TODO: this needs to be allocated and coped as well (see text above). Will also require a delete in some flutter code, I assume
code->bytes = result.bytes().data();
code->length = result.bytes().size();
auto p = result.position();
auto tl = p.topLeft();
auto tr = p.topRight();
auto bl = p.bottomLeft();
auto br = p.bottomRight();
code->pos = new Pos{0, 0, tl.x, tl.y, tr.x, tr.y, bl.x, bl.y, br.x, br.y};
code->isInverted = result.isInverted();
code->isMirrored = result.isMirrored();
}
FUNCTION_ATTRIBUTE FUNCTION_ATTRIBUTE
void setLogEnabled(int enable) void setLogEnabled(int enable)
{ {
@ -32,7 +61,7 @@ extern "C"
{ {
long long start = get_now(); long long start = get_now();
ImageView image{reinterpret_cast<const uint8_t*>(bytes), width, height, ImageFormat::Lum}; ImageView image{reinterpret_cast<const uint8_t *>(bytes), width, height, ImageFormat::Lum};
if (cropWidth > 0 && cropHeight > 0 && cropWidth < width && cropHeight < height) if (cropWidth > 0 && cropHeight > 0 && cropWidth < width && cropHeight < height)
{ {
image = image.cropped(width / 2 - cropWidth / 2, height / 2 - cropHeight / 2, cropWidth, cropHeight); image = image.cropped(width / 2 - cropWidth / 2, height / 2 - cropHeight / 2, cropWidth, cropHeight);
@ -58,7 +87,7 @@ extern "C"
{ {
long long start = get_now(); long long start = get_now();
ImageView image{reinterpret_cast<const uint8_t*>(bytes), width, height, ImageFormat::Lum}; ImageView image{reinterpret_cast<const uint8_t *>(bytes), width, height, ImageFormat::Lum};
if (cropWidth > 0 && cropHeight > 0 && cropWidth < width && cropHeight < height) if (cropWidth > 0 && cropHeight > 0 && cropWidth < width && cropHeight < height)
{ {
image = image.cropped(width / 2 - cropWidth / 2, height / 2 - cropHeight / 2, cropWidth, cropHeight); image = image.cropped(width / 2 - cropWidth / 2, height / 2 - cropHeight / 2, cropWidth, cropHeight);
@ -111,34 +140,4 @@ extern "C"
platform_log("Encode Barcode in: %d ms\n", evalInMillis); platform_log("Encode Barcode in: %d ms\n", evalInMillis);
return result; return result;
} }
FUNCTION_ATTRIBUTE
void resultToCodeResult(struct CodeResult *code, Result result)
{
string text = result.text();
code->text = new char[text.length() + 1];
strcpy(code->text, text.c_str());
code->isValid = result.isValid();
string error = result.error().msg();
code->error = new char[error.length() + 1];
strcpy(code->error, error.c_str());
code->format = static_cast<int>(result.format());
// TODO: this needs to be allocated and coped as well (see text above). Will also require a delete in some flutter code, I assume
code->bytes = result.bytes().data();
code->length = result.bytes().size();
auto p = result.position();
auto tl = p.topLeft();
auto tr = p.topRight();
auto bl = p.bottomLeft();
auto br = p.bottomRight();
code->pos = new Pos{0, 0, tl.x, tl.y, tr.x, tr.y, bl.x, bl.y, br.x, br.y};
code->isInverted = result.isInverted();
code->isMirrored = result.isMirrored();
}
} }

3
src/native_zxing.h

@ -117,9 +117,6 @@ extern "C"
*/ */
struct EncodeResult encodeBarcode(char *contents, int width, int height, int format, int margin, int eccLevel); struct EncodeResult encodeBarcode(char *contents, int width, int height, int format, int margin, int eccLevel);
// Private functions
void resultToCodeResult(struct CodeResult *code, ZXing::Result result);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

2
src/zxing

@ -1 +1 @@
Subproject commit d98bd6e9d8026a49708b6576227fb7b5b6c41145 Subproject commit cee1d0e0d4424937c368f683dc3ee2478290ad39

2
zxscanner/lib/pages/home_page.dart

@ -48,7 +48,7 @@ class _HomePageState extends State<HomePage> {
bottomNavigationBar: ConvexAppBar( bottomNavigationBar: ConvexAppBar(
disableDefaultTabController: true, disableDefaultTabController: true,
style: TabStyle.fixedCircle, style: TabStyle.fixedCircle,
backgroundColor: Theme.of(context).bottomAppBarTheme.color, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
color: Theme.of(context).unselectedWidgetColor, color: Theme.of(context).unselectedWidgetColor,
activeColor: Theme.of(context).colorScheme.primary, activeColor: Theme.of(context).colorScheme.primary,
items: tabItems(), items: tabItems(),

94
zxscanner/pubspec.lock

@ -29,10 +29,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: archive name: archive
sha256: d6347d54a2d8028e0437e3c099f66fdb8ae02c4720c1e7534c9f24c10351f85d sha256: "0c8368c9b3f0abbc193b9d6133649a614204b528982bebc7026372d61677ce3a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.3.6" version: "3.3.7"
args: args:
dependency: transitive dependency: transitive
description: description:
@ -125,10 +125,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: camera name: camera
sha256: ad1c53c554a2f3e5708f3b01eb738d60b902bb61f7f4ad420c65c715e65a7379 sha256: "7afc256902062cab191540c09908b98bc71e93d5e20b6486dbee51aa7731e9b2"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.10.3+2" version: "0.10.4"
camera_android: camera_android:
dependency: transitive dependency: transitive
description: description:
@ -229,10 +229,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: conventional_commit name: conventional_commit
sha256: "8eee25c315cf1946215d02d598402ca75cfee8a8ab482f3fac34cb0717323afa" sha256: dec15ad1118f029c618651a4359eb9135d8b88f761aa24e4016d061cd45948f2
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.0" version: "0.6.0+1"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@ -325,10 +325,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: flex_color_scheme name: flex_color_scheme
sha256: "03a0ad67cc224b20aab9f9a775a6cef76c8f884887902a2d94635c187858b31b" sha256: ba6b2e19aa6bcfebed8f74486b4359e1399e5f285a9b697107e14e27f2963415
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.1.2" version: "7.0.1"
flex_seed_scheme: flex_seed_scheme:
dependency: transitive dependency: transitive
description: description:
@ -403,7 +403,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "1.1.1" version: "1.1.2"
font_awesome_flutter: font_awesome_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
@ -512,10 +512,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: image_picker name: image_picker
sha256: cb25f04595a88450970dbe727243ba8cd21b6f7e0d7d1fc5b789fc6f52e95494 sha256: "8b0efbf350ba4f2be1531d629396a994983d0c02f4a82a128aed84d954b90cfa"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.8.7+1" version: "0.8.7+2"
image_picker_android: image_picker_android:
dependency: transitive dependency: transitive
description: description:
@ -536,10 +536,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: image_picker_ios name: image_picker_ios
sha256: d4cb8ab04f770dab9d04c7959e5f6d22e8c5280343d425f9344f93832cf58445 sha256: a1546ff5861fc15812953d4733b520c3d371cec3d2859a001ff04c46c4d81883
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.8.7+2" version: "0.8.7+3"
image_picker_platform_interface: image_picker_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -600,10 +600,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: markdown name: markdown
sha256: b3c60dee8c2af50ad0e6e90cceba98e47718a6ee0a7a6772c77846a0cc21f78b sha256: d95a9d12954aafc97f984ca29baaa7690ed4d9ec4140a23ad40580bcdb6c87f5
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "7.0.1" version: "7.0.2"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -624,10 +624,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: melos name: melos
sha256: cd8e7db0250ee822c5354a8214afc751b6c1c41aadfbbef927456d509d953244 sha256: "993ac467e7a36bd832a6cdabbe18a0487c30bc52b5cca14e476a824679ebdce0"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.0" version: "3.0.1"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -704,10 +704,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: path_provider_foundation name: path_provider_foundation
sha256: "818b2dc38b0f178e0ea3f7cf3b28146faab11375985d815942a68eee11c2d0f7" sha256: ad4c4d011830462633f03eb34445a45345673dfd4faf1ab0b4735fbd93b19183
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.2.1" version: "2.2.2"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
@ -832,74 +832,74 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: share_plus name: share_plus
sha256: "8c6892037b1824e2d7e8f59d54b3105932899008642e6372e5079c6939b4b625" sha256: "692261968a494e47323dcc8bc66d8d52e81bc27cb4b808e4e8d7e8079d4cc01a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.3.1" version: "6.3.2"
share_plus_platform_interface: share_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: share_plus_platform_interface name: share_plus_platform_interface
sha256: "82ddd4ab9260c295e6e39612d4ff00390b9a7a21f1bb1da771e2f232d80ab8a1" sha256: "0c6e61471bd71b04a138b8b588fa388e66d8b005e6f2deda63371c5c505a0981"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.2.0" version: "3.2.1"
shared_preferences: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:
name: shared_preferences name: shared_preferences
sha256: "78528fd87d0d08ffd3e69551173c026e8eacc7b7079c82eb6a77413957b7e394" sha256: "858aaa72d8f61637d64e776aca82e1c67e6d9ee07979123c5d17115031c1b13b"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.20" version: "2.1.0"
shared_preferences_android: shared_preferences_android:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_android name: shared_preferences_android
sha256: ad423a80fe7b4e48b50d6111b3ea1027af0e959e49d485712e134863d9c1c521 sha256: "8304d8a1f7d21a429f91dee552792249362b68a331ac5c3c1caf370f658873f6"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.17" version: "2.1.0"
shared_preferences_foundation: shared_preferences_foundation:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_foundation name: shared_preferences_foundation
sha256: "1e755f8583229f185cfca61b1d80fb2344c9d660e1c69ede5450d8f478fa5310" sha256: "0c1c16c56c9708aa9c361541a6f0e5cc6fc12a3232d866a687a7b7db30032b07"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.5" version: "2.2.1"
shared_preferences_linux: shared_preferences_linux:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_linux name: shared_preferences_linux
sha256: "3a59ed10890a8409ad0faad7bb2957dab4b92b8fbe553257b05d30ed8af2c707" sha256: "9d387433ca65717bbf1be88f4d5bb18f10508917a8fa2fb02e0fd0d7479a9afa"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.5" version: "2.2.0"
shared_preferences_platform_interface: shared_preferences_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_platform_interface name: shared_preferences_platform_interface
sha256: "824bfd02713e37603b2bdade0842e47d56e7db32b1dcdd1cae533fb88e2913fc" sha256: fb5cf25c0235df2d0640ac1b1174f6466bd311f621574997ac59018a6664548d
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.2.0"
shared_preferences_web: shared_preferences_web:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_web name: shared_preferences_web
sha256: "0dc2633f215a3d4aa3184c9b2c5766f4711e4e5a6b256e62aafee41f89f1bfb8" sha256: "74083203a8eae241e0de4a0d597dbedab3b8fef5563f33cf3c12d7e93c655ca5"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.6" version: "2.1.0"
shared_preferences_windows: shared_preferences_windows:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_windows name: shared_preferences_windows
sha256: "71bcd669bb9cdb6b39f22c4a7728b6d49e934f6cba73157ffa5a54f1eed67436" sha256: "5e588e2efef56916a3b229c3bfe81e6a525665a454519ca51dbcc4236a274173"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.5" version: "2.2.0"
shelf: shelf:
dependency: transitive dependency: transitive
description: description:
@ -1037,18 +1037,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_android name: url_launcher_android
sha256: dd729390aa936bf1bdf5cd1bc7468ff340263f80a2c4f569416507667de8e3c8 sha256: a52628068d282d01a07cd86e6ba99e497aa45ce8c91159015b2416907d78e411
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.26" version: "6.0.27"
url_launcher_ios: url_launcher_ios:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_ios name: url_launcher_ios
sha256: "3dedc66ca3c0bef9e6a93c0999aee102556a450afcc1b7bcfeace7a424927d92" sha256: "9af7ea73259886b92199f9e42c116072f05ff9bea2dcb339ab935dfc957392c2"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.1.3" version: "6.1.4"
url_launcher_linux: url_launcher_linux:
dependency: transitive dependency: transitive
description: description:
@ -1061,10 +1061,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_macos name: url_launcher_macos
sha256: "0ef2b4f97942a16523e51256b799e9aa1843da6c60c55eefbfa9dbc2dcb8331a" sha256: "91ee3e75ea9dadf38036200c5d3743518f4a5eb77a8d13fda1ee5764373f185e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.4" version: "3.0.5"
url_launcher_platform_interface: url_launcher_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -1117,18 +1117,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: web_socket_channel name: web_socket_channel
sha256: ca49c0bc209c687b887f30527fb6a9d80040b072cc2990f34b9bec3e7663101b sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.0" version: "2.4.0"
win32: win32:
dependency: transitive dependency: transitive
description: description:
name: win32 name: win32
sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.3" version: "3.1.4"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:

2
zxscanner/pubspec.yaml

@ -10,7 +10,7 @@ environment:
dependencies: dependencies:
convex_bottom_bar: ^3.2.0 convex_bottom_bar: ^3.2.0
cupertino_icons: ^1.0.5 cupertino_icons: ^1.0.5
flex_color_scheme: ^6.1.2 flex_color_scheme: ^7.0.1
flutter: flutter:
sdk: flutter sdk: flutter
flutter_localizations: flutter_localizations:

Loading…
Cancel
Save