Skip to content

Commit 5b2c9b0

Browse files
author
Nathan Fallet
authored
Merge pull request #107 from richy486/main
2 parents a147b22 + 11b7c1e commit 5b2c9b0

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Sources/CodeScanner/CodeScanner.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public struct ScanResult {
3737

3838
/// The image of the code that was matched
3939
public let image: UIImage?
40+
41+
/// The corner coordinates of the scanned code.
42+
public let corners: [CGPoint]
4043
}
4144

4245
/// The operating mode for CodeScannerView.

Sources/CodeScanner/ScannerViewController.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ extension CodeScannerView {
6868
if qrCodeLink == "" {
6969
didFail(reason: .badOutput)
7070
} else {
71-
let result = ScanResult(string: qrCodeLink, type: .qr, image: qrcodeImg)
71+
let corners = [
72+
feature.bottomLeft,
73+
feature.bottomRight,
74+
feature.topRight,
75+
feature.topLeft
76+
]
77+
let result = ScanResult(string: qrCodeLink, type: .qr, image: qrcodeImg, corners: corners)
7278
found(result)
7379
}
7480

@@ -125,7 +131,7 @@ extension CodeScannerView {
125131
// Send back their simulated data, as if it was one of the types they were scanning for
126132
found(ScanResult(
127133
string: parentView.simulatedData,
128-
type: parentView.codeTypes.first ?? .qr, image: nil
134+
type: parentView.codeTypes.first ?? .qr, image: nil, corners: []
129135
))
130136
}
131137

@@ -446,7 +452,7 @@ extension CodeScannerView {
446452
isCapturing = true
447453

448454
handler = { [self] image in
449-
let result = ScanResult(string: stringValue, type: readableObject.type, image: image)
455+
let result = ScanResult(string: stringValue, type: readableObject.type, image: image, corners: readableObject.corners)
450456

451457
switch parentView.scanMode {
452458
case .once:

0 commit comments

Comments
 (0)