Update 20250117 12:30
This commit is contained in:
@@ -100,6 +100,7 @@
|
||||
<Compile Include="Barcoded\LinearSymbol.cs" />
|
||||
<Compile Include="Barcoded\LinearVectors.cs" />
|
||||
<Compile Include="Barcodes.cs" />
|
||||
<Compile Include="clsBarI25.cs" />
|
||||
<Compile Include="Datamatrix\C40TextState.cs" />
|
||||
<Compile Include="Datamatrix\Class1.cs" />
|
||||
<Compile Include="Datamatrix\DmtxBestLine.cs" />
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace BarcodeLib.UI
|
||||
{
|
||||
this.cbxreportname.Items.Add(file.Name);
|
||||
}
|
||||
this.cbxreportname.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
@@ -45,13 +46,15 @@ namespace BarcodeLib.UI
|
||||
DataTable dt = new DataTable();
|
||||
DataSet dataSet = new DataSet();
|
||||
dt.Columns.Add("barcode");
|
||||
dt.Columns.Add("barcodetext");
|
||||
for (int i = 0; i < Convert.ToInt32(textBox1.Text); i++)
|
||||
{
|
||||
DataRow dr = dt.NewRow();
|
||||
string s;
|
||||
s = i.ToString();
|
||||
while (s.Length < 8) { s = "0" + s; };
|
||||
dr[0] = "" + s;
|
||||
dr[0] = Bar25I(s);
|
||||
dr[1] = s;
|
||||
dt.Rows.Add(dr);
|
||||
}
|
||||
dataSet.Tables.Add(dt);
|
||||
@@ -75,6 +78,7 @@ namespace BarcodeLib.UI
|
||||
DataTable dt = new DataTable();
|
||||
DataSet dataSet = new DataSet();
|
||||
dt.Columns.Add("barcode");
|
||||
dt.Columns.Add("barcodetext");
|
||||
for (int i = 0; i < Convert.ToInt32(textBox1.Text); i++)
|
||||
{
|
||||
DataRow dr = dt.NewRow();
|
||||
@@ -87,7 +91,8 @@ namespace BarcodeLib.UI
|
||||
while (s.Length < 5) { s = "0" + s; };
|
||||
s = DateTime.Now.Year.ToString()+s;
|
||||
s = s+Helper.DivFnkt.modulo10(s).ToString();
|
||||
dr[0] = s;
|
||||
dr[0] = Bar25I(s);
|
||||
dr[1] = s;
|
||||
dt.Rows.Add(dr);
|
||||
}
|
||||
dataSet.Tables.Add(dt);
|
||||
@@ -107,5 +112,60 @@ namespace BarcodeLib.UI
|
||||
|
||||
|
||||
}
|
||||
public bool IsNumeric(string value)
|
||||
{
|
||||
return value.All(char.IsNumber);
|
||||
}
|
||||
public string Bar25I(string BarTextIn)
|
||||
{
|
||||
string Bar25IRet = default;
|
||||
string BarTextOut = "";
|
||||
string TempString = "";
|
||||
long CharValue = 0;
|
||||
string barcodeout = "";
|
||||
// Initialize input and output strings
|
||||
BarTextOut = "";
|
||||
BarTextIn = BarTextIn.Trim();
|
||||
|
||||
// Throw away non-numeric data
|
||||
TempString = "";
|
||||
for (int II = 1, loopTo = BarTextIn.Length; II <= loopTo; II++)
|
||||
{
|
||||
if (IsNumeric(BarTextIn.Substring(II - 1, 1)))
|
||||
{
|
||||
TempString = TempString + BarTextIn.Substring(II - 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// If not an even number of digits, add a leading 0
|
||||
if (TempString.Length % 2 == 1)
|
||||
{
|
||||
TempString = "0" + TempString;
|
||||
}
|
||||
|
||||
// Break digit pairs up and convert to characters- build output string
|
||||
for (int II = 1, loopTo1 = TempString.Length; II <= loopTo1; II += 2)
|
||||
{
|
||||
// Break string into pairs of digits and get value
|
||||
CharValue = Convert.ToInt32(TempString.Substring(II - 1, 2));
|
||||
// translate value to ASCII and save in BarTextOut
|
||||
if (CharValue < 90)
|
||||
{
|
||||
BarTextOut = BarTextOut + (char)(CharValue + 33);
|
||||
}
|
||||
else
|
||||
{
|
||||
BarTextOut = BarTextOut + (char)(CharValue + 71);
|
||||
}
|
||||
}
|
||||
|
||||
// Build ouput string, trailing space for Windows rasterization bug
|
||||
barcodeout = "{" + BarTextOut + "} ";
|
||||
|
||||
// Return the string
|
||||
Bar25IRet = barcodeout;
|
||||
return Bar25IRet;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
162
BarcodeLib/clsBarI25.cs
Normal file
162
BarcodeLib/clsBarI25.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarcodeLib
|
||||
{
|
||||
public class clsBarI25
|
||||
{
|
||||
public Image GetBarI25(Color forecolor, Color backcolor, string text, string barcodefontname, int barcodefontsize, int imagewidth, int imageheight, string zusatztext, string zusatzfontname, int zusatfontsize, int rotation)
|
||||
{
|
||||
return DrawText1(forecolor, backcolor,barcodefontname,barcodefontsize,text, imagewidth,imageheight,zusatztext,zusatzfontname,zusatfontsize,rotation);
|
||||
}
|
||||
|
||||
public string Bar25I(string BarTextIn)
|
||||
{
|
||||
string Bar25IRet = default;
|
||||
string BarTextOut = "";
|
||||
string TempString = "";
|
||||
long CharValue = 0;
|
||||
string barcodeout = "";
|
||||
// Initialize input and output strings
|
||||
BarTextOut = "";
|
||||
BarTextIn = BarTextIn.Trim();
|
||||
|
||||
// Throw away non-numeric data
|
||||
TempString = "";
|
||||
for (int II = 1, loopTo = BarTextIn.Length; II <= loopTo; II++)
|
||||
{
|
||||
if (IsNumeric(BarTextIn.Substring(II - 1, 1)))
|
||||
{
|
||||
TempString = TempString + BarTextIn.Substring(II - 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// If not an even number of digits, add a leading 0
|
||||
if (TempString.Length % 2 == 1)
|
||||
{
|
||||
TempString = "0" + TempString;
|
||||
}
|
||||
|
||||
// Break digit pairs up and convert to characters- build output string
|
||||
for (int II = 1, loopTo1 = TempString.Length; II <= loopTo1; II += 2)
|
||||
{
|
||||
// Break string into pairs of digits and get value
|
||||
CharValue = Convert.ToInt32(TempString.Substring(II - 1, 2));
|
||||
// translate value to ASCII and save in BarTextOut
|
||||
if (CharValue < 90)
|
||||
{
|
||||
BarTextOut = BarTextOut + (char)(CharValue + 33);
|
||||
}
|
||||
else
|
||||
{
|
||||
BarTextOut = BarTextOut + (char)(CharValue + 71);
|
||||
}
|
||||
}
|
||||
|
||||
// Build ouput string, trailing space for Windows rasterization bug
|
||||
barcodeout = "{" + BarTextOut + "} ";
|
||||
|
||||
// Return the string
|
||||
Bar25IRet = barcodeout;
|
||||
return Bar25IRet;
|
||||
}
|
||||
|
||||
public bool IsNumeric(string value)
|
||||
{
|
||||
return value.All(char.IsNumber);
|
||||
}
|
||||
public Image DrawText1(Color foreColor, Color backColor, string fontName, int fontSize, string txt, int width, int height, string zusatz,string zusatzfontname, int zusatzfontsize , int rotation)
|
||||
{
|
||||
Bitmap img = new Bitmap(width, height);
|
||||
Graphics Gimg = Graphics.FromImage(img);
|
||||
Font imgFont = new Font(fontName, fontSize);
|
||||
PointF imgPoint = new PointF(5, 5);
|
||||
SolidBrush bForeColor = new SolidBrush(foreColor);
|
||||
SolidBrush bBackColor = new SolidBrush(backColor);
|
||||
Gimg.FillRectangle(bBackColor, 0, 0, width, height);
|
||||
Gimg.DrawString(txt, imgFont, bForeColor, imgPoint);
|
||||
Font fzFont = new Font(zusatzfontname, zusatzfontsize);
|
||||
|
||||
SizeF textSize = Gimg.MeasureString(zusatz, fzFont, 50);
|
||||
|
||||
PointF imgPointZusatz = new PointF(width - textSize.Width - 15, 30);
|
||||
Gimg.DrawString(zusatz, fzFont, bForeColor, imgPointZusatz);
|
||||
|
||||
return RotateImage(img, rotation, true, true, Color.White);
|
||||
//img.Save(imagePath, ImageFormat.Jpeg);
|
||||
}
|
||||
|
||||
public static Bitmap RotateImage(Image inputImage, float angleDegrees, bool upsizeOk,
|
||||
bool clipOk, Color backgroundColor)
|
||||
{
|
||||
// Test for zero rotation and return a clone of the input image
|
||||
if (angleDegrees == 0f)
|
||||
return (Bitmap)inputImage.Clone();
|
||||
|
||||
// Set up old and new image dimensions, assuming upsizing not wanted and clipping OK
|
||||
int oldWidth = inputImage.Width;
|
||||
int oldHeight = inputImage.Height;
|
||||
int newWidth = oldWidth;
|
||||
int newHeight = oldHeight;
|
||||
float scaleFactor = 1f;
|
||||
|
||||
// If upsizing wanted or clipping not OK calculate the size of the resulting bitmap
|
||||
if (upsizeOk || !clipOk)
|
||||
{
|
||||
double angleRadians = angleDegrees * Math.PI / 180d;
|
||||
|
||||
double cos = Math.Abs(Math.Cos(angleRadians));
|
||||
double sin = Math.Abs(Math.Sin(angleRadians));
|
||||
newWidth = (int)Math.Round(oldWidth * cos + oldHeight * sin);
|
||||
newHeight = (int)Math.Round(oldWidth * sin + oldHeight * cos);
|
||||
}
|
||||
|
||||
// If upsizing not wanted and clipping not OK need a scaling factor
|
||||
if (!upsizeOk && !clipOk)
|
||||
{
|
||||
scaleFactor = Math.Min((float)oldWidth / newWidth, (float)oldHeight / newHeight);
|
||||
newWidth = oldWidth;
|
||||
newHeight = oldHeight;
|
||||
}
|
||||
|
||||
// Create the new bitmap object. If background color is transparent it must be 32-bit,
|
||||
// otherwise 24-bit is good enough.
|
||||
Bitmap newBitmap = new Bitmap(newWidth, newHeight, backgroundColor == Color.Transparent ?
|
||||
PixelFormat.Format32bppArgb : PixelFormat.Format24bppRgb);
|
||||
newBitmap.SetResolution(inputImage.HorizontalResolution, inputImage.VerticalResolution);
|
||||
|
||||
// Create the Graphics object that does the work
|
||||
using (Graphics graphicsObject = Graphics.FromImage(newBitmap))
|
||||
{
|
||||
graphicsObject.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
graphicsObject.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
graphicsObject.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
||||
// Fill in the specified background color if necessary
|
||||
if (backgroundColor != Color.Transparent)
|
||||
graphicsObject.Clear(backgroundColor);
|
||||
|
||||
// Set up the built-in transformation matrix to do the rotation and maybe scaling
|
||||
graphicsObject.TranslateTransform(newWidth / 2f, newHeight / 2f);
|
||||
|
||||
if (scaleFactor != 1f)
|
||||
graphicsObject.ScaleTransform(scaleFactor, scaleFactor);
|
||||
|
||||
graphicsObject.RotateTransform(angleDegrees);
|
||||
graphicsObject.TranslateTransform(-oldWidth / 2f, -oldHeight / 2f);
|
||||
|
||||
// Draw the result
|
||||
graphicsObject.DrawImage(inputImage, 0, 0);
|
||||
}
|
||||
|
||||
return newBitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
4f8677c8e85a9757b986fd73821645a4a6e9753ca3cd4d4f52977c7093d08212
|
||||
29442f56ffe6512195e0a44c4b5996ec63580c54f5e48400620b56772a6c35f0
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user