Example #1
0
        public static BitmapImage Export(Common.ErrorCorrectionLevel errorCorrectionLevel, string inputText, int moduleSize, Brush darkBrush, Brush lightBrush)
        {
            BitmapImage bitmapImage;

            using (var ms = CreateQrCode(errorCorrectionLevel, inputText, moduleSize, darkBrush, lightBrush))
            {
                bitmapImage = CreateBitmapFromStream(ms);
            }

            return(bitmapImage);
        }
Example #2
0
        private static MemoryStream CreateQrCode(Common.ErrorCorrectionLevel errorCorrectionLevel, string inputText, int moduleSize, Brush darkBrush, Brush lightBrush)
        {
            var encoder = new QrEncoder((ErrorCorrectionLevel)errorCorrectionLevel);

            QrCode qrCode;

            encoder.TryEncode(inputText, out qrCode);

            var gRenderer = new GraphicsRenderer(new FixedModuleSize(moduleSize, QuietZoneModules.Two), darkBrush, lightBrush);

            var ms = new MemoryStream();

            gRenderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, ms);
            return(ms);
        }