Skip to main content

Posts

Showing posts from August, 2018

SWIFT PLAYGROUND / QR Code Generator

This is a quick test to make QR Code Generator that will run on Swift Playground app on iPad. I sourced some of the code online from few forums. The resulting QR Image on "Playground Preview" is stretched, however it seems to still work when I am using iPhone camera to scan it. Ideally the Playground Preview should not be stretched like this and keeping the QR image square. Saving the QR Code itself is another mystery. The whole code is actually very simple, taking advantage of Core Image CIFilter "CIQRCodeGenerator" as below: import Foundation import UIKit import PlaygroundSupport let data = "https://youtube.com/c/jimmygunawan".data(using: .utf8) let filter = CIFilter(name: "CIQRCodeGenerator", withInputParameters: ["inputMessage" : data, "inputCorrectionLevel":"L"]) let ciimage = filter!.outputImage! let transform = CGAffineTransform(scaleX: 20.0, y: 20.0) let image = ciimage.transformed(by: tran