Skip to content

Commit

Permalink
port SHA-1: 75dbbb00dd10a5f3683553e1d56b8209b9db48e2
Browse files Browse the repository at this point in the history
  • Loading branch information
micjahn committed Feb 18, 2023
1 parent 107a20e commit 7e4fdc5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Source/lib/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#if NETFX_CORE && !WINDOWS_UWP
[assembly: AssemblyTitle("zxing.net for windows rt")]
#endif
[assembly: AssemblyDescription("port of the java based barcode scanning library for .net (java zxing 06.05.2022 01:01:14)")]
[assembly: AssemblyDescription("port of the java based barcode scanning library for .net (java zxing 16.05.2022 16:28:14)")]
[assembly: AssemblyCompany("ZXing.Net Development")]
[assembly: AssemblyProduct("ZXing.Net")]
[assembly: AssemblyCopyright("Copyright © 2012")]
Expand Down
51 changes: 26 additions & 25 deletions Source/lib/datamatrix/encoder/HighLevelEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,37 +292,41 @@ internal static int lookAheadTestIntern(String msg, int startpos, int currentMod
charCounts[currentMode] = 0;
}

int charsProcessed = 0;
var charsProcessed = 0;
var mins = new byte[6];
var intCharCounts = new int[6];
while (true)
{
//step K
if ((startpos + charsProcessed) == msg.Length)
{
var min = Int32.MaxValue;
var mins = new byte[6];
var intCharCounts = new int[6];
min = findMinimums(charCounts, intCharCounts, min, mins);
SupportClass.Fill(mins, (byte)0);
SupportClass.Fill(intCharCounts, 0);
var min = findMinimums(charCounts, intCharCounts, Int32.MaxValue, mins);
var minCount = getMinimumCount(mins);

if (intCharCounts[Encodation.ASCII] == min)
{
return Encodation.ASCII;
}
if (minCount == 1 && mins[Encodation.BASE256] > 0)
{
return Encodation.BASE256;
}
if (minCount == 1 && mins[Encodation.EDIFACT] > 0)
if (minCount == 1)
{
return Encodation.EDIFACT;
}
if (minCount == 1 && mins[Encodation.TEXT] > 0)
{
return Encodation.TEXT;
}
if (minCount == 1 && mins[Encodation.X12] > 0)
{
return Encodation.X12;
if (mins[Encodation.BASE256] > 0)
{
return Encodation.BASE256;
}
if (mins[Encodation.EDIFACT] > 0)
{
return Encodation.EDIFACT;
}
if (mins[Encodation.TEXT] > 0)
{
return Encodation.TEXT;
}
if (mins[Encodation.X12] > 0)
{
return Encodation.X12;
}
}
return Encodation.C40;
}
Expand Down Expand Up @@ -415,8 +419,8 @@ internal static int lookAheadTestIntern(String msg, int startpos, int currentMod
//step R
if (charsProcessed >= 4)
{
var intCharCounts = new int[6];
var mins = new byte[6];
SupportClass.Fill(mins, (byte)0);
SupportClass.Fill(intCharCounts, 0);
findMinimums(charCounts, intCharCounts, Int32.MaxValue, mins);

if (intCharCounts[Encodation.ASCII] < min(intCharCounts[Encodation.BASE256],
Expand Down Expand Up @@ -491,11 +495,9 @@ private static int min(int f1, int f2, int f3, int f4)

private static int findMinimums(float[] charCounts, int[] intCharCounts, int min, byte[] mins)
{
SupportClass.Fill(mins, (byte)0);
for (int i = 0; i < 6; i++)
{
intCharCounts[i] = (int)Math.Ceiling(charCounts[i]);
int current = intCharCounts[i];
int current = (intCharCounts[i] = (int)Math.Ceiling(charCounts[i]));
if (min > current)
{
min = current;
Expand All @@ -504,7 +506,6 @@ private static int findMinimums(float[] charCounts, int[] intCharCounts, int min
if (min == current)
{
mins[i]++;

}
}
return min;
Expand Down

0 comments on commit 7e4fdc5

Please sign in to comment.