Reputation: 13616
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?
Upvotes: 0
Views: 215
Reputation:
I dont have any problems with your code:
Of course, mb you have to change width and height for testing.
Upvotes: 3
Reputation: 10367
You code works successfully (I checked). It seems because of img.Width
or img.Height
are large values and your program are still working (so that you can not see an result). try this loop and see result:
for (int i = 0; i < 50; i++)
{
for (int j = 0; j < 50; j++)
{
...
Upvotes: 4