前提・実現したいこと
z=の式が小数点以下なので今エラーが出ているのですが、doubleやfloatで変換してみてもやり方が悪いのかうまくいきませんでした。
修正方法修正方法を教えてください。お願いします。
書いたコード
private void button1_Click(object sender, EventArgs e) { // Retrieve the image. Bitmap image1 = new Bitmap(200, 200); int x, y, z; // Loop through the images pixels to reset color. int xpitch = image1.Width / 100; int ypitch = image1.Height / 100; for (x = 0; x < image1.Width; x += xpitch) { for (y = 0; y < image1.Height; y += ypitch) { z = -0.138 + (-0.019 * x) + (-0.070 * y) + (0.005 * x * x) + (0.0 * x * y) + (0.013 * y * y); if (z * 0.2 <= 0.5) { Color pixelColor = image1.GetPixel(x, y); Color newColor = Color.FromArgb(pixelColor.R, 0, 0); image1.SetPixel(x, y, newColor); } } // Set the PictureBox to display the image. pictureBox1.Image = image1; } } } }
発生している問題・エラーメッセージ
エラー CS0266 型 'double' を 'int' に暗黙的に変換できません。明示的な変換が存在します (キャストが不足していないかどうかを確認してください)
試したこと
ここに問題に対して試したことを記載してください。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/08 20:21