Created
January 21, 2014 01:15
-
-
Save mikebluestein/8532580 to your computer and use it in GitHub Desktop.
Display a QR Code in Xamarin.iOS using Core Image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var qrCode = new CIQRCodeGenerator { | |
Message = NSData.FromString (someText), | |
CorrectionLevel = "Q" | |
}.OutputImage; | |
UIGraphics.BeginImageContext (new SizeF (qrCode.Extent.Width * 8, qrCode.Extent.Height * 8)); | |
var cgCtx = UIGraphics.GetCurrentContext (); | |
var ciCtx = CIContext.FromOptions (null); | |
cgCtx.InterpolationQuality = CGInterpolationQuality.None; | |
cgCtx.DrawImage (cgCtx.GetClipBoundingBox (), ciCtx.CreateCGImage (qrCode, qrCode.Extent)); | |
using (var image = UIGraphics.GetImageFromCurrentImageContext ()) { | |
someUIView.Image = image; | |
} | |
UIGraphics.EndImageContext(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment