I have thise segment of C# code:
private void btn_getPixels_Click_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
listBox1.Items.Add("Pixel Color");
try
{
Bitmap img = new Bitmap(pictureBox1.Image);
Color c;
for (int i = 0; i < img.Width; i++)
{
for (int j = 0; j < img.Height; j++)
{
c = img.GetPixel(i, j);
listBox1.Items.Add(i + "," + j + " " + c.Name);
}
}
MessageBox.Show("SUCESSFULLY DONE");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
The problem is that after external loop is done,I dont see any result in listBox1.
Any idea how to fix this problema?
You code works successfully (I checked). It seems because of
img.Widthorimg.Heightare large values and your program are still working (so that you can not see an result). try this loop and see result: