Skip to content

Commit

Permalink
Merge pull request #156 from ajamaica/feature/qrcode_helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ajamaica authored Feb 20, 2022
2 parents b232de0 + 109bb8a commit d9f6bc2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Sources/Solana/Pay/QrCodeHelper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// QRCodeHelper.swift
//
//
// Created by Arturo Jamaica on 2022/02/20.
//
#if canImport(UIKit)
#if canImport(CoreImage)
import Foundation
import UIKit
import CoreImage

class QRCodeHelper {
func generateQRCode(from url: URL) -> UIImage? {
let data = url.absoluteString.data(using: String.Encoding.ascii)

if let filter = CIFilter(name: "CIQRCodeGenerator") {
filter.setValue(data, forKey: "inputMessage")
let transform = CGAffineTransform(scaleX: 3, y: 3)

if let output = filter.outputImage?.transformed(by: transform) {
return UIImage(ciImage: output)
}
}

return nil
}
}
#endif
#endif

0 comments on commit d9f6bc2

Please sign in to comment.