回答編集履歴
2
追記
answer
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
コメント欄では黒と書きましたが、実際は赤でした。
|
20
20
|
newColor は点が描画される中心の色を加工して赤成分だけ残しています。
|
21
21
|
なので、白い所に描かれると赤くなり、青いところや緑のところに描かれると黒くなります。
|
22
|
-
そして黒いところに描かれると
|
22
|
+
そして黒いところや赤いところに描かれると地の色と同じ色になって見えなくなります。
|
23
23
|
仕様変更を検討したほうがいいと思います。
|
24
24
|
|
25
25
|
```C#
|
1
追記
answer
CHANGED
@@ -11,4 +11,78 @@
|
|
11
11
|
```
|
12
12
|
|
13
13
|
元のソースではコンパイル時に例外が発生します。
|
14
|
-
質問前にコンパイルできるかどうかを確認してください。
|
14
|
+
質問前にコンパイルできるかどうかを確認してください。
|
15
|
+
|
16
|
+
#追記
|
17
|
+
|
18
|
+
点が見えにくかったので拡大してみました。
|
19
|
+
コメント欄では黒と書きましたが、実際は赤でした。
|
20
|
+
newColor は点が描画される中心の色を加工して赤成分だけ残しています。
|
21
|
+
なので、白い所に描かれると赤くなり、青いところや緑のところに描かれると黒くなります。
|
22
|
+
そして黒いところに描かれると黒くなって見えなくなります。
|
23
|
+
仕様変更を検討したほうがいいと思います。
|
24
|
+
|
25
|
+
```C#
|
26
|
+
using System;
|
27
|
+
using System.Collections.Generic;
|
28
|
+
using System.ComponentModel;
|
29
|
+
using System.Data;
|
30
|
+
using System.Drawing;
|
31
|
+
using System.Linq;
|
32
|
+
using System.Text;
|
33
|
+
using System.Threading.Tasks;
|
34
|
+
using System.Windows.Forms;
|
35
|
+
|
36
|
+
namespace WindowsFormsApp1
|
37
|
+
{
|
38
|
+
public partial class Form1 : Form
|
39
|
+
{
|
40
|
+
public Form1()
|
41
|
+
{
|
42
|
+
InitializeComponent();
|
43
|
+
}
|
44
|
+
|
45
|
+
private void button1_Click(object sender, EventArgs e)
|
46
|
+
{
|
47
|
+
if (openFileDialog1.ShowDialog() != DialogResult.OK) return;
|
48
|
+
|
49
|
+
// Retrieve the image.
|
50
|
+
Bitmap image1 = new Bitmap(openFileDialog1.FileName);
|
51
|
+
//Bitmap image1 = new Bitmap(200, 200);
|
52
|
+
|
53
|
+
|
54
|
+
int x, y;
|
55
|
+
|
56
|
+
// Loop through the images pixels to reset color.
|
57
|
+
int xpitch = image1.Width / 100;
|
58
|
+
int ypitch = image1.Height / 100;
|
59
|
+
|
60
|
+
|
61
|
+
var graphics = Graphics.FromImage(image1);
|
62
|
+
for (x = 0; x < image1.Width; x += xpitch)
|
63
|
+
{
|
64
|
+
for (y = 0; y < image1.Height; y += ypitch)
|
65
|
+
{
|
66
|
+
double z = -0.138 + (-0.019 * x) + (-0.070 * y) + (0.005 * x * x) +
|
67
|
+
(0.0 * x * y) + (0.013 * y * y);
|
68
|
+
|
69
|
+
|
70
|
+
if (z % 0.2 <= 0.005)
|
71
|
+
{
|
72
|
+
Color pixelColor = image1.GetPixel(x, y);
|
73
|
+
Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
|
74
|
+
newColor = Color.Red;
|
75
|
+
//image1.SetPixel(x, y, newColor);
|
76
|
+
graphics.FillEllipse(new SolidBrush(newColor), x, y, 5, 5);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
// Set the PictureBox to display the image.
|
82
|
+
|
83
|
+
pictureBox1.Image = image1;
|
84
|
+
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
```
|