回答編集履歴

2

追記

2018/10/13 10:35

投稿

Zuishin
Zuishin

スコア28660

test CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
  なので、白い所に描かれると赤くなり、青いところや緑のところに描かれると黒くなります。
42
42
 
43
- そして黒いところに描かれると黒くなって見えなくなります。
43
+ そして黒いところや赤いところに描かれると地の色と同じ色になって見えなくなります。
44
44
 
45
45
  仕様変更を検討したほうがいいと思います。
46
46
 

1

追記

2018/10/13 10:35

投稿

Zuishin
Zuishin

スコア28660

test CHANGED
@@ -25,3 +25,151 @@
25
25
  元のソースではコンパイル時に例外が発生します。
26
26
 
27
27
  質問前にコンパイルできるかどうかを確認してください。
28
+
29
+
30
+
31
+ #追記
32
+
33
+
34
+
35
+ 点が見えにくかったので拡大してみました。
36
+
37
+ コメント欄では黒と書きましたが、実際は赤でした。
38
+
39
+ newColor は点が描画される中心の色を加工して赤成分だけ残しています。
40
+
41
+ なので、白い所に描かれると赤くなり、青いところや緑のところに描かれると黒くなります。
42
+
43
+ そして黒いところに描かれると黒くなって見えなくなります。
44
+
45
+ 仕様変更を検討したほうがいいと思います。
46
+
47
+
48
+
49
+ ```C#
50
+
51
+ using System;
52
+
53
+ using System.Collections.Generic;
54
+
55
+ using System.ComponentModel;
56
+
57
+ using System.Data;
58
+
59
+ using System.Drawing;
60
+
61
+ using System.Linq;
62
+
63
+ using System.Text;
64
+
65
+ using System.Threading.Tasks;
66
+
67
+ using System.Windows.Forms;
68
+
69
+
70
+
71
+ namespace WindowsFormsApp1
72
+
73
+ {
74
+
75
+ public partial class Form1 : Form
76
+
77
+ {
78
+
79
+ public Form1()
80
+
81
+ {
82
+
83
+ InitializeComponent();
84
+
85
+ }
86
+
87
+
88
+
89
+ private void button1_Click(object sender, EventArgs e)
90
+
91
+ {
92
+
93
+ if (openFileDialog1.ShowDialog() != DialogResult.OK) return;
94
+
95
+
96
+
97
+ // Retrieve the image.
98
+
99
+ Bitmap image1 = new Bitmap(openFileDialog1.FileName);
100
+
101
+ //Bitmap image1 = new Bitmap(200, 200);
102
+
103
+
104
+
105
+
106
+
107
+ int x, y;
108
+
109
+
110
+
111
+ // Loop through the images pixels to reset color.
112
+
113
+ int xpitch = image1.Width / 100;
114
+
115
+ int ypitch = image1.Height / 100;
116
+
117
+
118
+
119
+
120
+
121
+ var graphics = Graphics.FromImage(image1);
122
+
123
+ for (x = 0; x < image1.Width; x += xpitch)
124
+
125
+ {
126
+
127
+ for (y = 0; y < image1.Height; y += ypitch)
128
+
129
+ {
130
+
131
+ double z = -0.138 + (-0.019 * x) + (-0.070 * y) + (0.005 * x * x) +
132
+
133
+ (0.0 * x * y) + (0.013 * y * y);
134
+
135
+
136
+
137
+
138
+
139
+ if (z % 0.2 <= 0.005)
140
+
141
+ {
142
+
143
+ Color pixelColor = image1.GetPixel(x, y);
144
+
145
+ Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
146
+
147
+ newColor = Color.Red;
148
+
149
+ //image1.SetPixel(x, y, newColor);
150
+
151
+ graphics.FillEllipse(new SolidBrush(newColor), x, y, 5, 5);
152
+
153
+ }
154
+
155
+ }
156
+
157
+ }
158
+
159
+
160
+
161
+ // Set the PictureBox to display the image.
162
+
163
+
164
+
165
+ pictureBox1.Image = image1;
166
+
167
+
168
+
169
+ }
170
+
171
+ }
172
+
173
+ }
174
+
175
+ ```