Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mikebluestein
Created January 21, 2014 01:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mikebluestein/8532580 to your computer and use it in GitHub Desktop.
Save mikebluestein/8532580 to your computer and use it in GitHub Desktop.
Display a QR Code in Xamarin.iOS using Core Image
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