diff --git a/src/PhotoCollector/Infrastructure/CVRHelper.cs b/src/PhotoCollector/Infrastructure/CVRHelper.cs index da55f86..46b93bb 100644 --- a/src/PhotoCollector/Infrastructure/CVRHelper.cs +++ b/src/PhotoCollector/Infrastructure/CVRHelper.cs @@ -18,7 +18,7 @@ public class CVRHelper : IDisposable while (!this._cts.IsCancellationRequested) { this.ScanCardReader(); - await Task.Delay(600); + await Task.Delay(700); } }); } @@ -34,7 +34,7 @@ public class CVRHelper : IDisposable break; } } - if(cvrStatus == 1) + if (cvrStatus == 1) { if (!connetctd) { @@ -70,19 +70,14 @@ public class CVRHelper : IDisposable { try { - var imgData = new byte[40960]; var length = 40960; - CVRSDK.GetBMPData(ref imgData[0], ref length); - //Image myImage = null; - //using (var myStream = new MemoryStream()) - //{ - // for (var i = 0; i < length; i++) - // { - // myStream.WriteByte(imgData[i]); - // } - // myImage = Image.FromStream(myStream); - //} - var image = "data:image/jpeg;base64," + Convert.ToBase64String(imgData); + //var imgData = new byte[length]; + //CVRSDK.GetJpgData(ref imgData[0], ref length); + //var image = "data:image/jpeg;base64," + Convert.ToBase64String(imgData); + using var bmp = new ImageMagick.MagickImage(Path.Combine(AppContext.BaseDirectory, "zp.bmp")); + using var ms = new MemoryStream(); + bmp.Write(ms, ImageMagick.MagickFormat.Jpeg); + var image = "data:image/jpeg;base64," + Convert.ToBase64String(ms.ToArray()); byte[] name = new byte[128]; length = 128; CVRSDK.GetPeopleName(ref name[0], ref length); diff --git a/src/PhotoCollector/Infrastructure/CVRSDK.cs b/src/PhotoCollector/Infrastructure/CVRSDK.cs index 1f19563..f8a4f42 100644 --- a/src/PhotoCollector/Infrastructure/CVRSDK.cs +++ b/src/PhotoCollector/Infrastructure/CVRSDK.cs @@ -67,4 +67,7 @@ internal class CVRSDK [DllImport("Termb.dll", EntryPoint = "GetJpgData", CharSet = CharSet.Ansi, SetLastError = false, CallingConvention = CallingConvention.StdCall)] public static extern int GetJpgData(ref byte btBmp, ref int nLen); + + [DllImport("Termb.dll", EntryPoint = "Getbase64JpgDataU", CharSet = CharSet.Ansi, SetLastError = false, CallingConvention = CallingConvention.StdCall)] + public static extern int Getbase64JpgData(ref byte btBmp, ref int nLen); } \ No newline at end of file diff --git a/src/PhotoCollector/PhotoCollector.csproj b/src/PhotoCollector/PhotoCollector.csproj index d459db1..3ac757c 100644 --- a/src/PhotoCollector/PhotoCollector.csproj +++ b/src/PhotoCollector/PhotoCollector.csproj @@ -22,6 +22,7 @@ + diff --git a/src/PhotoCollector/Properties/PublishProfiles/FolderProfile.pubxml b/src/PhotoCollector/Properties/PublishProfiles/FolderProfile.pubxml index 7fe20ff..e96c75b 100644 --- a/src/PhotoCollector/Properties/PublishProfiles/FolderProfile.pubxml +++ b/src/PhotoCollector/Properties/PublishProfiles/FolderProfile.pubxml @@ -6,10 +6,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121. Release Any CPU - bin\Release\net6.0-windows\publish\win-x64\ + bin\Release\net6.0-windows\publish\win-x86\ FileSystem net6.0-windows - win-x64 + win-x86 true True False diff --git a/src/WebApiTestServer/wwwroot/index.html b/src/WebApiTestServer/wwwroot/index.html index dab0a52..30578a9 100644 --- a/src/WebApiTestServer/wwwroot/index.html +++ b/src/WebApiTestServer/wwwroot/index.html @@ -6,6 +6,10 @@ 模拟接口