前提・実現したいこと
c#でfor文を使って点を描画する点を描画するプログラムプログラムを作成しようとしています。
点の描画はpixelでしているのですが、座標(x、y)の範囲は挿入した画像のサイズになっている。なので点を描画しても画像の0~10と対応しません。
描画する点の座標(x、y)を画像の0~10に合わせたいのですがのですがどうすればよろしいでしょうか。
よろしくお願いします。
発生している問題・エラーメッセージ
private void button1_Click(object sender, EventArgs e) { // Retrieve the image. Bitmap image1 = new Bitmap(@”.¥images¥blue.png”); int x, y; // Loop through the images pixels to reset color. for (x = 0; x < image1.Width; x++) { for (y = 0; y < image1.Height; y++) { if (x * y < 5000) { 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; } } } }
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー