63 lines
2.3 KiB
C#
63 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using DataMatrix.net;
|
|
|
|
namespace OnDocAPI_NetFramework.Helper
|
|
{
|
|
public class ImageHelper
|
|
{
|
|
public void CalculateImageSize(System.Drawing.Image img, out double targetHeight, out double targetWidth)
|
|
{
|
|
targetHeight = 0;
|
|
targetWidth = 0;
|
|
|
|
}
|
|
|
|
public System.Drawing.Image Datamatrix(int width, int heigth, int left, int top, List<string>values)
|
|
{
|
|
//int imageWidth = 304; // 250; // 142;
|
|
//int imageHeight = 45; // 37; // 31;
|
|
|
|
|
|
//JToken jObject = JToken.Parse(value);
|
|
//bool show = jObject.Value<bool>("Show");
|
|
//if (show)
|
|
//{
|
|
// string dokumentId = jObject.Value<string>("DokumentId");
|
|
// if (dokumentId == null)
|
|
// {
|
|
// dokumentId = "123456Edoka Dok Id fehlt!";
|
|
// }
|
|
// string avqAuthExtlRef = jObject.Value<string>("AvqAuthExtlRef");
|
|
// string PartnerNr = jObject.Value<string>("PartnerNr");
|
|
// string PersonNr = jObject.Value<string>("PersonNr");
|
|
// string PersonNr1 = jObject.Value<string>("PersonNr1");
|
|
|
|
// string text = "imaq$" + dokumentId.Substring(6) + "$0002$" + avqAuthExtlRef + "$" + PartnerNr + "$" + PersonNr + "$" + PersonNr1;
|
|
// Bitmap dataMatrixBitmap = new DmtxImageEncoder().EncodeImage(text); //.Save("test1.png");
|
|
|
|
// Bitmap textBitmap = new Bitmap(4000, 600);
|
|
// using (Graphics g = Graphics.FromImage(textBitmap))
|
|
// {
|
|
// g.DrawImage(dataMatrixBitmap, 0, 0, 600, 600);
|
|
// g.DrawString(dokumentId.Substring(6) + " U", new Font("Futura Book", 84), Brushes.Black, 650, 360);
|
|
// }
|
|
// byte[] textPng = null;
|
|
// using (MemoryStream m = new MemoryStream())
|
|
// {
|
|
// textBitmap.Save(m, System.Drawing.Imaging.ImageFormat.Png);
|
|
// textPng = m.GetBuffer();
|
|
// }
|
|
//}
|
|
|
|
return null;
|
|
}
|
|
|
|
}
|
|
} |