94 lines
3.2 KiB
C#
94 lines
3.2 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 CodGenController : Controller
|
|
{
|
|
// GET: CodGen
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un QR code dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="hSize">Altezza immagine</param>
|
|
/// <param name="wSize">Larghezza immagine</param>
|
|
/// <returns></returns>
|
|
public ActionResult QR(string id, int hSize = 600, int wSize = 600)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.QR_CODE;
|
|
return utils.getImage2D(ref id, hSize, wSize, formato);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un DataMatrix code dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="hSize">Altezza immagine</param>
|
|
/// <param name="wSize">Larghezza immagine</param>
|
|
/// <returns></returns>
|
|
public ActionResult DataMatrix(string id, int hSize = 300, int wSize = 600)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.DATA_MATRIX;
|
|
return utils.getImage2D(ref id, hSize, wSize, formato);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un Aztec code dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="hSize">Altezza immagine</param>
|
|
/// <param name="wSize">Larghezza immagine</param>
|
|
/// <returns></returns>
|
|
public ActionResult Aztec(string id, int hSize = 600, int wSize = 600)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.AZTEC;
|
|
return utils.getImage2D(ref id, hSize, wSize, formato);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un Aztec code dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="hSize">Altezza immagine</param>
|
|
/// <param name="wSize">Larghezza immagine</param>
|
|
/// <returns></returns>
|
|
public ActionResult Pdf417(string id, int hSize = 300, int wSize = 600)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.PDF_417;
|
|
return utils.getImage2D(ref id, hSize, wSize, formato);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un Code39 1D dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="pureBarcode">mostrare valore SOLO come codice (false --> testo sotto)</param>
|
|
/// <param name="hSize">Altezza immagine</param>
|
|
/// <returns></returns>
|
|
public ActionResult code39(string id, bool pureBarcode = false, int hSize = 70)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.CODE_39;
|
|
return utils.getImage(id, hSize, formato, pureBarcode);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce un Code128 1D dato valore
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="pureBarcode">mostrare valore SOLO come codice (false --> testo sotto)</param>
|
|
/// <param name="hSize">Altezza immagine</param>
|
|
/// <returns></returns>
|
|
public ActionResult Code128(string id, bool pureBarcode = false, int hSize = 70)
|
|
{
|
|
BarcodeFormat formato = BarcodeFormat.CODE_128;
|
|
return utils.getImage(id, hSize, formato, pureBarcode);
|
|
}
|
|
}
|
|
} |