private void LoadFromQR(Bitmap bitmap)
{
ZXing.BarcodeReader reader = new ZXing.BarcodeReader();
reader.PossibleFormats = new[] { ZXing.BarcodeFormat.QR_CODE };
reader.TryHarder = true;
ZXing.Result[] results = reader.DecodeMultiple(bitmap);
if (results != null && results.Length > 0)
{
try
{
byte[] rawBytes = null;
if (results.Length == 1)
rawBytes = results[0].RawBytes;
else
{
QRSelectDialog qrSelectDialog = new QRSelectDialog(bitmap, results.Select(r => RectangleFromResultPoints(r.ResultPoints)).ToArray());
if (qrSelectDialog.ShowDialog() != DialogResult.OK)
return;
rawBytes = results[qrSelectDialog.SelectedIndex].RawBytes;
}
AC.Pattern pattern = AC.Pattern.CreateFromRawData(rawBytes);
LoadPattern(pattern);
}
catch (NotImplementedException)
{
MessageBox.Show("This type of pattern is currently not supported.", Text);
}
}
else
{
MessageBox.Show("A valid QR code was not found in the selected image.", Text);
}
}