provide image width/height on Android even when returnImage is false
Showing
2 changed files
with
7 additions
and
8 deletions
| @@ -120,7 +120,11 @@ class MobileScanner( | @@ -120,7 +120,11 @@ class MobileScanner( | ||
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | if (!returnImage) { | 122 | if (!returnImage) { |
| 123 | - mobileScannerCallback(barcodeMap, null, null, null) | 123 | + mobileScannerCallback( |
| 124 | + barcodeMap, | ||
| 125 | + null, | ||
| 126 | + mediaImage.width, | ||
| 127 | + mediaImage.height) | ||
| 124 | return@addOnSuccessListener | 128 | return@addOnSuccessListener |
| 125 | } | 129 | } |
| 126 | 130 |
| @@ -47,22 +47,17 @@ class MobileScannerHandler( | @@ -47,22 +47,17 @@ class MobileScannerHandler( | ||
| 47 | private var analyzerResult: MethodChannel.Result? = null | 47 | private var analyzerResult: MethodChannel.Result? = null |
| 48 | 48 | ||
| 49 | private val callback: MobileScannerCallback = { barcodes: List<Map<String, Any?>>, image: ByteArray?, width: Int?, height: Int? -> | 49 | private val callback: MobileScannerCallback = { barcodes: List<Map<String, Any?>>, image: ByteArray?, width: Int?, height: Int? -> |
| 50 | - if (image != null) { | ||
| 51 | barcodeHandler.publishEvent(mapOf( | 50 | barcodeHandler.publishEvent(mapOf( |
| 52 | "name" to "barcode", | 51 | "name" to "barcode", |
| 53 | "data" to barcodes, | 52 | "data" to barcodes, |
| 53 | + // The image dimensions are always provided. | ||
| 54 | + // The image bytes are only non-null when `returnImage` is true. | ||
| 54 | "image" to mapOf( | 55 | "image" to mapOf( |
| 55 | "bytes" to image, | 56 | "bytes" to image, |
| 56 | "width" to width?.toDouble(), | 57 | "width" to width?.toDouble(), |
| 57 | "height" to height?.toDouble(), | 58 | "height" to height?.toDouble(), |
| 58 | ) | 59 | ) |
| 59 | )) | 60 | )) |
| 60 | - } else { | ||
| 61 | - barcodeHandler.publishEvent(mapOf( | ||
| 62 | - "name" to "barcode", | ||
| 63 | - "data" to barcodes | ||
| 64 | - )) | ||
| 65 | - } | ||
| 66 | } | 61 | } |
| 67 | 62 | ||
| 68 | private val errorCallback: MobileScannerErrorCallback = {error: String -> | 63 | private val errorCallback: MobileScannerErrorCallback = {error: String -> |
-
Please register or login to post a comment