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-09-04 12:52:18 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
02e01023dfd4d14659f66749f2b90033ee7a7493
02e01023
1 parent
2f7de30a
add jpeg data extension & toMap extension
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
macos/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift
macos/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift
View file @
02e0102
...
...
@@ -494,6 +494,45 @@ class MapArgumentReader {
}
extension
CGImage
{
public
func
jpegData
(
compressionQuality
:
CGFloat
)
->
Data
?
{
let
mutableData
=
CFDataCreateMutable
(
nil
,
0
)
let
formatHint
:
CFString
if
#available(macOS 11.0, *)
{
formatHint
=
UTType
.
jpeg
.
identifier
as
CFString
}
else
{
formatHint
=
kUTTypeJPEG
}
guard
let
destination
=
CGImageDestinationCreateWithData
(
mutableData
!
,
formatHint
,
1
,
nil
)
else
{
return
nil
}
let
options
:
NSDictionary
=
[
kCGImageDestinationLossyCompressionQuality
:
compressionQuality
,
]
CGImageDestinationAddImage
(
destination
,
self
,
options
)
if
!
CGImageDestinationFinalize
(
destination
)
{
return
nil
}
return
mutableData
as
Data
?
}
}
extension
VNBarcodeObservation
{
public
func
toMap
()
->
[
String
:
Any
?]
{
return
[
"rawValue"
:
self
.
payloadStringValue
??
""
,
"format"
:
self
.
symbology
.
toInt
??
-
1
,
]
}
}
extension
VNBarcodeSymbology
{
static
func
fromInt
(
_
mapValue
:
Int
)
->
VNBarcodeSymbology
?
{
if
#available(macOS 12.0, *)
{
...
...
Please
register
or
login
to post a comment