mirror of
https://github.com/cyanfish/naps2.git
synced 2024-08-16 18:50:45 +03:00
parent
e556233274
commit
9e806e6697
@ -1,4 +1,5 @@
|
|||||||
using System.Text;
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
using GrpcDotNetNamedPipes;
|
using GrpcDotNetNamedPipes;
|
||||||
using static NAPS2.Remoting.ProcessCoordinatorService;
|
using static NAPS2.Remoting.ProcessCoordinatorService;
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ public class ProcessCoordinator(string basePath, string pipeNameFormat)
|
|||||||
using var procFile = new FileStream(ProcFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
|
using var procFile = new FileStream(ProcFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
|
||||||
procFile.SetLength(0);
|
procFile.SetLength(0);
|
||||||
using var writer = new StreamWriter(procFile, Encoding.UTF8, 1024);
|
using var writer = new StreamWriter(procFile, Encoding.UTF8, 1024);
|
||||||
writer.WriteLine(Process.GetCurrentProcess().Id);
|
writer.WriteLine(Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -104,7 +105,7 @@ public class ProcessCoordinator(string basePath, string pipeNameFormat)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var reader = new FileStream(ProcFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
using var reader = new FileStream(ProcFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
var id = int.Parse(new StreamReader(reader).ReadLine()?.Trim() ?? "");
|
var id = int.Parse(new StreamReader(reader).ReadLine()?.Trim() ?? "", CultureInfo.InvariantCulture);
|
||||||
return Process.GetProcessById(id);
|
return Process.GetProcessById(id);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
|
using System.Globalization;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -276,8 +277,10 @@ public class TesseractOcrEngine : IOcrEngine
|
|||||||
var bounds = (0, 0, 0, 0);
|
var bounds = (0, 0, 0, 0);
|
||||||
if (ParseData(element, "bbox", 4, out string[] parts))
|
if (ParseData(element, "bbox", 4, out string[] parts))
|
||||||
{
|
{
|
||||||
int x1 = int.Parse(parts[1]), y1 = int.Parse(parts[2]);
|
int x1 = int.Parse(parts[1], CultureInfo.InvariantCulture),
|
||||||
int x2 = int.Parse(parts[3]), y2 = int.Parse(parts[4]);
|
y1 = int.Parse(parts[2], CultureInfo.InvariantCulture);
|
||||||
|
int x2 = int.Parse(parts[3], CultureInfo.InvariantCulture),
|
||||||
|
y2 = int.Parse(parts[4], CultureInfo.InvariantCulture);
|
||||||
bounds = (x1, y1, x2 - x1, y2 - y1);
|
bounds = (x1, y1, x2 - x1, y2 - y1);
|
||||||
}
|
}
|
||||||
return bounds;
|
return bounds;
|
||||||
@ -288,7 +291,7 @@ public class TesseractOcrEngine : IOcrEngine
|
|||||||
int fontSize = 0;
|
int fontSize = 0;
|
||||||
if (ParseData(element, "x_fsize", 1, out string[] parts))
|
if (ParseData(element, "x_fsize", 1, out string[] parts))
|
||||||
{
|
{
|
||||||
fontSize = int.Parse(parts[1]);
|
fontSize = int.Parse(parts[1], CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
return fontSize;
|
return fontSize;
|
||||||
}
|
}
|
||||||
@ -299,8 +302,8 @@ public class TesseractOcrEngine : IOcrEngine
|
|||||||
float b = 0;
|
float b = 0;
|
||||||
if (ParseData(element, "baseline", 2, out string[] parts))
|
if (ParseData(element, "baseline", 2, out string[] parts))
|
||||||
{
|
{
|
||||||
m = float.Parse(parts[1]);
|
m = float.Parse(parts[1], CultureInfo.InvariantCulture);
|
||||||
b = float.Parse(parts[2]);
|
b = float.Parse(parts[2], CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
return (m, b);
|
return (m, b);
|
||||||
}
|
}
|
||||||
@ -310,7 +313,7 @@ public class TesseractOcrEngine : IOcrEngine
|
|||||||
float angle = 0;
|
float angle = 0;
|
||||||
if (ParseData(element, "textangle", 1, out string[] parts))
|
if (ParseData(element, "textangle", 1, out string[] parts))
|
||||||
{
|
{
|
||||||
angle = float.Parse(parts[1]);
|
angle = float.Parse(parts[1], CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user