Commit 1d3c4232 authored by Clint Mourlevat's avatar Clint Mourlevat

Adding QrCode Action

parent 0baba17a
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using QRCoder;
using UnityEngine;
using Color = System.Drawing.Color;
namespace Stratis.Guru.Controllers
{
......@@ -31,5 +38,16 @@ namespace Stratis.Guru.Controllers
{
return View();
}
[Route("qr/{value}")]
public IActionResult Qr(string value)
{
var memoryStream = new MemoryStream();
var qrGenerator = new QRCodeGenerator();
var qrCodeData = qrGenerator.CreateQrCode(value, QRCodeGenerator.ECCLevel.L);
var qrCode = new QRCode(qrCodeData);
qrCode.GetGraphic(20, Color.Black, Color.White, false).Save(memoryStream, ImageFormat.Png);
return File(memoryStream.ToArray(), "image/png");
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment