private void Camera_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
try
{
using (Bitmap bitmap = (Bitmap)[Link]())
{
// Skip null or zero-sized frames
if (bitmap == null || [Link] == 0 || [Link] == 0)
return;
using (Bitmap bitmapForDecode = new Bitmap([Link], [Link],
PixelFormat.Format24bppRgb))
{
using (Graphics g = [Link](bitmapForDecode))
{
[Link](bitmap, new Rectangle(0, 0, [Link],
[Link]));
}
var reader = new [Link]
{
AutoRotate = true,
TryInverted = true,
Options = new [Link]
{
TryHarder = true,
PossibleFormats = new List<[Link]>
{
[Link].QR_CODE
}
}
};
Result result = null;
try
{
result = [Link](bitmapForDecode);
}
catch (NullReferenceException nre)
{
[Link]("ZXing NullReferenceException: " +
[Link]);
}
catch (Exception decodeEx)
{
[Link]("Decode failed: " + [Link]);
}
if (result != null)
{
[Link]();
Invoke(new MethodInvoker(() =>
{
webView.EnsureCoreWebView2Async();
[Link] = new Uri([Link]);
[Link] = true;
}));
}
}
[Link]?.Dispose();
[Link] = (Bitmap)[Link]();
}
}
catch (Exception ex)
{
[Link]("Camera frame processing error: " + [Link]);
}
}