回答編集履歴
1
見直しキャンペーン中
answer
CHANGED
@@ -1,64 +1,64 @@
|
|
1
|
-
試したところ、これと言って設定せずに読めました。
|
2
|
-
ただし入力画像はシビアみたいです(枠があったりするとダメだった)
|
3
|
-
そういう意味では事前処理が必要になりそうです。
|
4
|
-
|
5
|
-
```
|
6
|
-
using System.ComponentModel;
|
7
|
-
using System.Drawing;
|
8
|
-
using System.Linq;
|
9
|
-
using System.Windows.Forms;
|
10
|
-
using ZXing;
|
11
|
-
|
12
|
-
namespace Questions268785
|
13
|
-
{
|
14
|
-
public partial class Form1 : Form
|
15
|
-
{
|
16
|
-
private readonly PictureBox pictureBox;
|
17
|
-
private readonly TextBox textBox;
|
18
|
-
public Form1()
|
19
|
-
{
|
20
|
-
InitializeComponent();
|
21
|
-
|
22
|
-
textBox = new TextBox
|
23
|
-
{
|
24
|
-
Dock = DockStyle.Fill,
|
25
|
-
Multiline = true,
|
26
|
-
};
|
27
|
-
Controls.Add(textBox);
|
28
|
-
|
29
|
-
pictureBox = new PictureBox
|
30
|
-
{
|
31
|
-
Dock = DockStyle.Top,
|
32
|
-
SizeMode = PictureBoxSizeMode.AutoSize,
|
33
|
-
ImageLocation = "https://dic.nicovideo.jp/oekaki/323888.png", // OKっぽい
|
34
|
-
//ImageLocation = "https://www.qrcode.com/img/featurePage6/commonDataImage.png", // 明らかに変 当然?w(青枠の中だけに分ければ読めた)
|
35
|
-
};
|
36
|
-
pictureBox.LoadCompleted += PictureBox_LoadCompleted;
|
37
|
-
Controls.Add(pictureBox);
|
38
|
-
}
|
39
|
-
|
40
|
-
private void PictureBox_LoadCompleted(object sender, AsyncCompletedEventArgs e)
|
41
|
-
{
|
42
|
-
var reader = new BarcodeReader()
|
43
|
-
{
|
44
|
-
AutoRotate = true,
|
45
|
-
TryInverted = true,
|
46
|
-
Options = {
|
47
|
-
TryHarder = true,
|
48
|
-
PossibleFormats = new[] { BarcodeFormat.QR_CODE, },
|
49
|
-
},
|
50
|
-
};
|
51
|
-
var img = new Bitmap(pictureBox.Image);
|
52
|
-
var result = reader.DecodeMultiple(img);
|
53
|
-
img.Dispose();
|
54
|
-
|
55
|
-
textBox.Text = string.Join("\r\n\r\n", result.Select(x => x.Text));
|
56
|
-
}
|
57
|
-
}
|
58
|
-
}
|
59
|
-
```
|
60
|
-

|
61
|
-
|
62
|
-
検証に使用させていただいた画像
|
63
|
-
[QRコードとは (キューアールコードとは) [単語記事] - ニコニコ大百科](https://dic.nicovideo.jp/oekaki/323888.png)
|
1
|
+
試したところ、これと言って設定せずに読めました。
|
2
|
+
ただし入力画像はシビアみたいです(枠があったりするとダメだった)
|
3
|
+
そういう意味では事前処理が必要になりそうです。
|
4
|
+
|
5
|
+
```cs
|
6
|
+
using System.ComponentModel;
|
7
|
+
using System.Drawing;
|
8
|
+
using System.Linq;
|
9
|
+
using System.Windows.Forms;
|
10
|
+
using ZXing;
|
11
|
+
|
12
|
+
namespace Questions268785
|
13
|
+
{
|
14
|
+
public partial class Form1 : Form
|
15
|
+
{
|
16
|
+
private readonly PictureBox pictureBox;
|
17
|
+
private readonly TextBox textBox;
|
18
|
+
public Form1()
|
19
|
+
{
|
20
|
+
InitializeComponent();
|
21
|
+
|
22
|
+
textBox = new TextBox
|
23
|
+
{
|
24
|
+
Dock = DockStyle.Fill,
|
25
|
+
Multiline = true,
|
26
|
+
};
|
27
|
+
Controls.Add(textBox);
|
28
|
+
|
29
|
+
pictureBox = new PictureBox
|
30
|
+
{
|
31
|
+
Dock = DockStyle.Top,
|
32
|
+
SizeMode = PictureBoxSizeMode.AutoSize,
|
33
|
+
ImageLocation = "https://dic.nicovideo.jp/oekaki/323888.png", // OKっぽい
|
34
|
+
//ImageLocation = "https://www.qrcode.com/img/featurePage6/commonDataImage.png", // 明らかに変 当然?w(青枠の中だけに分ければ読めた)
|
35
|
+
};
|
36
|
+
pictureBox.LoadCompleted += PictureBox_LoadCompleted;
|
37
|
+
Controls.Add(pictureBox);
|
38
|
+
}
|
39
|
+
|
40
|
+
private void PictureBox_LoadCompleted(object sender, AsyncCompletedEventArgs e)
|
41
|
+
{
|
42
|
+
var reader = new BarcodeReader()
|
43
|
+
{
|
44
|
+
AutoRotate = true,
|
45
|
+
TryInverted = true,
|
46
|
+
Options = {
|
47
|
+
TryHarder = true,
|
48
|
+
PossibleFormats = new[] { BarcodeFormat.QR_CODE, },
|
49
|
+
},
|
50
|
+
};
|
51
|
+
var img = new Bitmap(pictureBox.Image);
|
52
|
+
var result = reader.DecodeMultiple(img);
|
53
|
+
img.Dispose();
|
54
|
+
|
55
|
+
textBox.Text = string.Join("\r\n\r\n", result.Select(x => x.Text));
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
```
|
60
|
+

|
61
|
+
|
62
|
+
検証に使用させていただいた画像
|
63
|
+
[QRコードとは (キューアールコードとは) [単語記事] - ニコニコ大百科](https://dic.nicovideo.jp/oekaki/323888.png)
|
64
64
|
[QRコードとは?|QRコードドットコム|株式会社デンソーウェーブ](https://www.qrcode.com/img/featurePage6/commonDataImage.png)
|