Skip to content

Commit

Permalink
Merge pull request #107 from richy486/main
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Fallet authored May 8, 2023
2 parents a147b22 + 11b7c1e commit 5b2c9b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Sources/CodeScanner/CodeScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public struct ScanResult {

/// The image of the code that was matched
public let image: UIImage?

/// The corner coordinates of the scanned code.
public let corners: [CGPoint]
}

/// The operating mode for CodeScannerView.
Expand Down
12 changes: 9 additions & 3 deletions Sources/CodeScanner/ScannerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ extension CodeScannerView {
if qrCodeLink == "" {
didFail(reason: .badOutput)
} else {
let result = ScanResult(string: qrCodeLink, type: .qr, image: qrcodeImg)
let corners = [
feature.bottomLeft,
feature.bottomRight,
feature.topRight,
feature.topLeft
]
let result = ScanResult(string: qrCodeLink, type: .qr, image: qrcodeImg, corners: corners)
found(result)
}

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

Expand Down Expand Up @@ -446,7 +452,7 @@ extension CodeScannerView {
isCapturing = true

handler = { [self] image in
let result = ScanResult(string: stringValue, type: readableObject.type, image: image)
let result = ScanResult(string: stringValue, type: readableObject.type, image: image, corners: readableObject.corners)

switch parentView.scanMode {
case .once:
Expand Down

0 comments on commit 5b2c9b0

Please sign in to comment.