Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2024-10-05 11:23:09 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
75208e479949f34de2dec49df423d45716f7130b
75208e47
1 parent
7d536b0c
provide image width/height on iOS/MacOS even when returnImage is false
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
ios/Classes/MobileScannerPlugin.swift
macos/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift
ios/Classes/MobileScannerPlugin.swift
View file @
75208e4
...
...
@@ -69,22 +69,18 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin {
return
}
if
(
!
MobileScannerPlugin
.
returnImage
)
{
barcodeHandler
.
publishEvent
([
"name"
:
"barcode"
,
"data"
:
barcodesMap
,
])
return
}
// The image dimensions are always provided.
// The image bytes are only non-null when `returnImage` is true.
let
imageData
:
[
String
:
Any
?]
=
[
"bytes"
:
MobileScannerPlugin
.
returnImage
?
FlutterStandardTypedData
(
bytes
:
image
.
jpegData
(
compressionQuality
:
0.8
)
!
)
:
nil
,
"width"
:
image
.
size
.
width
,
"height"
:
image
.
size
.
height
,
]
barcodeHandler
.
publishEvent
([
"name"
:
"barcode"
,
"data"
:
barcodesMap
,
"image"
:
[
"bytes"
:
FlutterStandardTypedData
(
bytes
:
image
.
jpegData
(
compressionQuality
:
0.8
)
!
),
"width"
:
image
.
size
.
width
,
"height"
:
image
.
size
.
height
,
],
"image"
:
imageData
,
])
},
torchModeChangeCallback
:
{
torchState
in
barcodeHandler
.
publishEvent
([
"name"
:
"torchState"
,
"data"
:
torchState
])
...
...
macos/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift
View file @
75208e4
...
...
@@ -156,7 +156,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
})
DispatchQueue
.
main
.
async
{
if
(
!
MobileScannerPlugin
.
returnImage
)
{
guard
let
image
=
cgImage
else
{
self
?
.
sink
?([
"name"
:
"barcode"
,
"data"
:
barcodes
.
map
({
$0
.
toMap
()
}),
...
...
@@ -164,14 +164,18 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
return
}
// The image dimensions are always provided.
// The image bytes are only non-null when `returnImage` is true.
let
imageData
:
[
String
:
Any
?]
=
[
"bytes"
:
MobileScannerPlugin
.
returnImage
?
FlutterStandardTypedData
(
bytes
:
image
.
jpegData
(
compressionQuality
:
0.8
)
!
)
:
nil
,
"width"
:
Double
(
image
.
width
),
"height"
:
Double
(
image
.
height
),
]
self
?
.
sink
?([
"name"
:
"barcode"
,
"data"
:
barcodes
.
map
({
$0
.
toMap
()
}),
"image"
:
cgImage
==
nil
?
nil
:
[
"bytes"
:
FlutterStandardTypedData
(
bytes
:
cgImage
!.
jpegData
(
compressionQuality
:
0.8
)
!
),
"width"
:
Double
(
cgImage
!.
width
),
"height"
:
Double
(
cgImage
!.
height
),
],
"image"
:
imageData
,
])
}
})
...
...
Please
register
or
login
to post a comment