94 lines
3.0 KiB
C#
94 lines
3.0 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing.Imaging;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using ZXing;
|
|
using ZXing.QrCode;
|
|
|
|
namespace QR_GEN.Controllers
|
|
{
|
|
public class GenController : Controller
|
|
{
|
|
// GET: Gen
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un QR code dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="h">Altezza immagine</param>
|
|
/// <param name="w">Larghezza immagine</param>
|
|
/// <returns></returns>
|
|
public ActionResult QR(string id, int h = 600, int w = 600)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.QR_CODE;
|
|
return utils.getImage2D(ref id, h, w, formato);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un DataMatrix code dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="h">Altezza immagine</param>
|
|
/// <param name="w">Larghezza immagine</param>
|
|
/// <returns></returns>
|
|
public ActionResult DataMatrix(string id, int h = 300, int w = 600)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.DATA_MATRIX;
|
|
return utils.getImage2D(ref id, h, w, formato);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un Aztec code dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="h">Altezza immagine</param>
|
|
/// <param name="w">Larghezza immagine</param>
|
|
/// <returns></returns>
|
|
public ActionResult Aztec(string id, int h = 600, int w = 600)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.AZTEC;
|
|
return utils.getImage2D(ref id, h, w, formato);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un Aztec code dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="h">Altezza immagine</param>
|
|
/// <param name="w">Larghezza immagine</param>
|
|
/// <returns></returns>
|
|
public ActionResult Pdf417(string id, int h = 300, int w = 600)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.PDF_417;
|
|
return utils.getImage2D(ref id, h, w, formato);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un Code39 1D dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="h">Altezza immagine</param>
|
|
/// <param name="showVal">Indica se mostrare ANCHE testo</param>
|
|
/// <returns></returns>
|
|
public ActionResult code39(string id, int h = 75, bool showVal = true)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.CODE_39;
|
|
return utils.getImage(id, h, formato, !showVal);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un Code128 1D dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="h">Altezza immagine</param>
|
|
/// <param name="showVal">Indica se mostrare ANCHE testo</param>
|
|
/// <returns></returns>
|
|
public ActionResult Code128(string id, int h = 75, bool showVal = true)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.CODE_128;
|
|
return utils.getImage(id, h, formato, !showVal);
|
|
}
|
|
}
|
|
} |