public Bitmap GenerateAndSaveQrBitmap(PayloadGenerator.Payload payload, string filename)
        {
            Bitmap bitmap = this.GenerateQrBitmap(payload);

            bitmap.Save(filename, this.Config.Codec, this.Config.EncoderParameters);
            return(bitmap);
        }
示例#2
0
        public FileContentResult GetQRImage(PayloadGenerator.Payload payload, Color backColor)
        {
            QRCodeData qRCodeData = generator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.M);

            using (QRCode qrCode = new QRCode(qRCodeData))
            {
                Bitmap qrImage = qrCode.GetGraphic(8, Color.Black, backColor, true);
                byte[] bytes   = BitmapToBytes(qrImage);
                return(new FileContentResult(bytes, "image/jpeg"));
            }
        }
        private void OnSave(PayloadGenerator.Payload payload)
        {
            if (this._saveFileDialog == null)
            {
                this._saveFileDialog = new SaveFileDialog()
                {
                    AddExtension    = true,
                    OverwritePrompt = true,
                };
            }

            this._saveFileDialog.Filter     = $"{this._helper.Config.Codec.FilenameExtension}|{this._helper.Config.Codec.FilenameExtension}";
            this._saveFileDialog.DefaultExt = this._helper.Config.Codec.FilenameExtension.Split(';')[0].Replace("*.", "");

            bool?result = this._saveFileDialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                Bitmap bitmap = this._helper.GenerateAndSaveQrBitmap(payload, this._saveFileDialog.FileName);
                this.Image = bitmap.ToWpfBitmap();
                this.MessageQueue.Enqueue("Image Saved.");
            }
        }
        private void SetImage(PayloadGenerator.Payload payload)
        {
            Bitmap bitmap = this._helper.GenerateQrBitmap(payload);

            this.Image = bitmap.ToWpfBitmap();
        }
        private QRCode CreateQrCode(PayloadGenerator.Payload payload)
        {
            QRCodeData qrCodeData = this._qrGenerator.CreateQrCode(payload, this._config.EccLevel);

            return(new QRCode(qrCodeData));
        }
        public Bitmap GenerateQrBitmap(PayloadGenerator.Payload payload)
        {
            QRCode qrCode = this.CreateQrCode(payload);

            return(this.CreateBitmap(qrCode));
        }
示例#7
0
 public FileContentResult GetQRImage(PayloadGenerator.Payload payload) => GetQRImage(payload, Color.White);