x64下无法通过api获取身份证照片

master
wanggang 4 years ago
parent 8fa7f8eb2f
commit 74a333cba4

@ -18,7 +18,7 @@ public class CVRHelper : IDisposable
while (!this._cts.IsCancellationRequested) while (!this._cts.IsCancellationRequested)
{ {
this.ScanCardReader(); this.ScanCardReader();
await Task.Delay(600); await Task.Delay(700);
} }
}); });
} }
@ -34,7 +34,7 @@ public class CVRHelper : IDisposable
break; break;
} }
} }
if(cvrStatus == 1) if (cvrStatus == 1)
{ {
if (!connetctd) if (!connetctd)
{ {
@ -70,19 +70,14 @@ public class CVRHelper : IDisposable
{ {
try try
{ {
var imgData = new byte[40960];
var length = 40960; var length = 40960;
CVRSDK.GetBMPData(ref imgData[0], ref length); //var imgData = new byte[length];
//Image myImage = null; //CVRSDK.GetJpgData(ref imgData[0], ref length);
//using (var myStream = new MemoryStream()) //var image = "data:image/jpeg;base64," + Convert.ToBase64String(imgData);
//{ using var bmp = new ImageMagick.MagickImage(Path.Combine(AppContext.BaseDirectory, "zp.bmp"));
// for (var i = 0; i < length; i++) using var ms = new MemoryStream();
// { bmp.Write(ms, ImageMagick.MagickFormat.Jpeg);
// myStream.WriteByte(imgData[i]); var image = "data:image/jpeg;base64," + Convert.ToBase64String(ms.ToArray());
// }
// myImage = Image.FromStream(myStream);
//}
var image = "data:image/jpeg;base64," + Convert.ToBase64String(imgData);
byte[] name = new byte[128]; byte[] name = new byte[128];
length = 128; length = 128;
CVRSDK.GetPeopleName(ref name[0], ref length); CVRSDK.GetPeopleName(ref name[0], ref length);

@ -67,4 +67,7 @@ internal class CVRSDK
[DllImport("Termb.dll", EntryPoint = "GetJpgData", CharSet = CharSet.Ansi, SetLastError = false, CallingConvention = CallingConvention.StdCall)] [DllImport("Termb.dll", EntryPoint = "GetJpgData", CharSet = CharSet.Ansi, SetLastError = false, CallingConvention = CallingConvention.StdCall)]
public static extern int GetJpgData(ref byte btBmp, ref int nLen); 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);
} }

@ -22,6 +22,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="8.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1020.30" /> <PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1020.30" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />

@ -6,10 +6,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup> <PropertyGroup>
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>Any CPU</Platform> <Platform>Any CPU</Platform>
<PublishDir>bin\Release\net6.0-windows\publish\win-x64\</PublishDir> <PublishDir>bin\Release\net6.0-windows\publish\win-x86\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol> <PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net6.0-windows</TargetFramework> <TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>true</SelfContained> <SelfContained>true</SelfContained>
<PublishSingleFile>True</PublishSingleFile> <PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun> <PublishReadyToRun>False</PublishReadyToRun>

@ -6,6 +6,10 @@
<title>模拟接口</title> <title>模拟接口</title>
<style> <style>
body { body {
margin:0;
padding:0;
border:none;
outline:none;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
} }
@ -19,6 +23,13 @@
position: relative; position: relative;
text-align: center; text-align: center;
display: inline-block; display: inline-block;
width:960px;
height:540px;
}
.videoWrapper video{
width:100%;
height:100%;
} }
.range { .range {
@ -71,13 +82,17 @@
</div> </div>
</div> </div>
<canvas id="canvas" width="358" height="441"></canvas> <canvas id="canvas" width="358" height="441"></canvas>
<img id="idCard" alt="" /> <img id="img" alt="" width="358" height="441" />
<hr />
<img id="idCard" width="102" height="126" alt="" />
<script> <script>
var appBasePath = navigator.userAgent.split('|')[1]; var appBasePath = navigator.userAgent.split('|')[1];
window.chrome.webview.postMessage({ command: "setStatus", message: `app at ${appBasePath}` }); window.chrome.webview.postMessage({ command: "setStatus", message: `app at ${appBasePath}` });
function onIdCardRead(card) { function onIdCardRead(card) {
document.getElementById('idCard').src = card.image; var img = document.getElementById('idCard');
img.src = card.image;
img.title = result.name;
} }
//文件夹浏览 //文件夹浏览
@ -106,7 +121,7 @@
alert(result.message); alert(result.message);
} }
else { else {
document.getElementById('idCard').src = `data:image/webp;base64,${result.base64}`; document.getElementById('img').src = `data:image/webp;base64,${result.base64}`;
} }
} }
@ -213,9 +228,9 @@
video.addEventListener("loadedmetadata", function (e) { video.addEventListener("loadedmetadata", function (e) {
video.width = e.srcElement.videoWidth; video.width = e.srcElement.videoWidth;
video.height = e.srcElement.videoHeight; video.height = e.srcElement.videoHeight;
var wrapper = document.querySelector('.videoWrapper'); //var wrapper = document.querySelector('.videoWrapper');
wrapper.style.width = video.width + 'px'; //wrapper.style.width = video.width + 'px';
wrapper.style.height = video.height + 'px'; //wrapper.style.height = video.height + 'px';
video.play(); video.play();
}); });
}, function (err) { }, function (err) {

Loading…
Cancel
Save