You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
4.0 KiB
90 lines
4.0 KiB
using BarcodeStandard;
|
|
using SkiaSharp;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.Remoting.Messaging;
|
|
using System.Security.AccessControl;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
|
|
namespace EDOKA_Barcode
|
|
{
|
|
public class EDOKABC
|
|
{
|
|
|
|
public System.Drawing.Image getimg(string barcodetype ,string inhalt,Int32 with, Int32 height)
|
|
{
|
|
Barcode bc = new Barcode();
|
|
SkiaSharp.SKImage skimage = bc.Encode(SetType(barcodetype), inhalt, with, height);
|
|
|
|
SKData stdata = skimage.Encode();
|
|
System.Drawing.Image img = System.Drawing.Image.FromStream(stdata.AsStream());
|
|
bc = null;
|
|
skimage.Dispose();
|
|
return img;
|
|
}
|
|
|
|
public string ImgAsBase64(string barcodetype, string inhalt, Int32 with, Int32 height)
|
|
{
|
|
System.Drawing.Image timg = getimg(barcodetype, inhalt, with, height);
|
|
using (MemoryStream m = new MemoryStream())
|
|
{
|
|
timg.Save(m, timg.RawFormat);
|
|
byte[] imageBytes = m.ToArray();
|
|
|
|
// Convert byte[] to Base64 String
|
|
string base64String = Convert.ToBase64String(imageBytes);
|
|
m.Dispose();
|
|
timg.Dispose();
|
|
return base64String;
|
|
}
|
|
}
|
|
|
|
public BarcodeStandard.Type SetType(string type)
|
|
{
|
|
|
|
switch (type)
|
|
{
|
|
case "UPC-A": return BarcodeStandard.Type.UpcA;
|
|
case "UPC-E": return BarcodeStandard.Type.UpcE;
|
|
case "UPC 2 Digit Ext.": return BarcodeStandard.Type.UpcSupplemental2Digit;
|
|
case "UPC 5 Digit Ext.": return BarcodeStandard.Type.UpcSupplemental5Digit;
|
|
case "EAN-13": return BarcodeStandard.Type.Ean13;
|
|
case "JAN-13": return BarcodeStandard.Type.Jan13;
|
|
case "EAN-8": return BarcodeStandard.Type.Ean8;
|
|
case "ITF-14": return BarcodeStandard.Type.Itf14;
|
|
case "Codabar": return BarcodeStandard.Type.Codabar;
|
|
case "PostNet": return BarcodeStandard.Type.PostNet;
|
|
case "Bookland/ISBN": return BarcodeStandard.Type.Bookland;
|
|
case "Code 11": return BarcodeStandard.Type.Code11;
|
|
case "Code 39": return BarcodeStandard.Type.Code39;
|
|
case "Code 39 Extended": return BarcodeStandard.Type.Code39Extended;
|
|
case "Code 39 Mod 43": return BarcodeStandard.Type.Code39Mod43;
|
|
case "Code 93": return BarcodeStandard.Type.Code93;
|
|
case "LOGMARS": return BarcodeStandard.Type.Logmars;
|
|
case "MSI Mod 10": return BarcodeStandard.Type.MsiMod10;
|
|
case "MSI Mod 11": return BarcodeStandard.Type.MsiMod11;
|
|
case "MSI 2 Mod 10": return BarcodeStandard.Type.Msi2Mod10;
|
|
case "MSI Mod 11 Mod 10": return BarcodeStandard.Type.MsiMod11Mod10;
|
|
case "Interleaved 2 of 5": return BarcodeStandard.Type.Industrial2Of5;
|
|
case "Interleaved 2 of 5 Mod 10": return BarcodeStandard.Type.Interleaved2Of5Mod10;
|
|
case "Standard 2 of 5": return BarcodeStandard.Type.Standard2Of5;
|
|
case "Standard 2 of 5 Mod 10": return BarcodeStandard.Type.Standard2Of5Mod10;
|
|
case "Code 128": return BarcodeStandard.Type.Code128;
|
|
case "Code 128-A": return BarcodeStandard.Type.Code128A;
|
|
case "Code 128-B": return BarcodeStandard.Type.Code128B;
|
|
case "Code 128-C": return BarcodeStandard.Type.Code128C;
|
|
case "Telepen": return BarcodeStandard.Type.Telepen;
|
|
case "FIM": return BarcodeStandard.Type.Fim;
|
|
case "Pharmacode": return BarcodeStandard.Type.Pharmacode;
|
|
case "IATA2of5": return BarcodeStandard.Type.IATA2of5;
|
|
default: return BarcodeStandard.Type.Unspecified;
|
|
}
|
|
}
|
|
}
|
|
}
|