Zxing Colorful . net

Asked

Viewed 58 times

0

I need to create a color qrcode using zxing.net however I can’t and I can’t find 1 tutorial on the internet even searching and trying for days, Does anyone have any idea how to develop 1 color qrcode using zxing and c#/.net. Help here my code to generate the qrcode.

CODE:

public static class QRHelper
{

    public static IHtmlString GenerateQrCode(this HtmlHelper html, string url)
    {
        int QRCODE_IMAGE_HEIGHT = 496;
        int QRCODE_IMAGE_WIDTH = 496;
        var qrWriter = new BarcodeWriter();
        qrWriter.Format = BarcodeFormat.QR_CODE;
        var BackgroundColor = Color.White;
        var ModuleColor = Color.Green;

        qrWriter.Options = new EncodingOptions() { Height = QRCODE_IMAGE_HEIGHT, Width = QRCODE_IMAGE_WIDTH };
        var ms = new MemoryStream();
        var q = qrWriter.Write(url);
        q.Save(ms, ImageFormat.Png);
        var img = new TagBuilder("img");
        string alt = "QR code";
        img.Attributes.Add("src", String.Format("data:image/png;base64,{0}", Convert.ToBase64String(ms.ToArray())));
        img.Attributes.Add("alt", alt);

        return MvcHtmlString.Create(img.ToString(TagRenderMode.SelfClosing));

    }

}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.