Question

List<Point> points = new List<Point>(); //How do I get coordinates Setpixel adaptation x, y, 

List<Point> points = new List<Point>();        
    private void button1_Click(object sender, EventArgs e)
    {           
        Bitmap img = new Bitmap(pictureBox1.Image);
        int width = img.Width;
        int height = img.Height;           

        for (int y = 0; y < height; y+= 5)
        {
            for (int x = 0; x < width; x+= 5)
            {
                Color pixelColor = img.GetPixel(x, y);

                if (pixelColor.ToArgb() == Color.Red.ToArgb())
                {
                    points.Add(new Point(x, y));
                }
                if (pixelColor.ToArgb() == Color.Red.ToArgb())
                    img.SetPixel(x, y, Color.White);                    
            }
            pictureBox1.Image = img;

        }
        return;
    }
    private void button2_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < points.Count; i++)
        {
            listBox1.Items.Add(points[i].ToString());
        }
    }
    private void button3_Click(object sender, EventArgs e)
    {
         Bitmap img = new Bitmap(pictureBox2.Image);
         int wid = Math.Min(img.Width, img.Width);
         int hgt = Math.Min(img.Height, img.Height);
         Bitmap bm3 = new Bitmap(wid, hgt);
         for (int ii = 0; ii < points.Count; ii++)//PROBLEM RİGHT HERE 
         { 
        for (int i = 0; i < points.Count; i++)
         {
             bm3.SetPixel(i, ii, Color.Red); //PROBLEM RİGHT HERE 

             pictureBox2.Image = bm3;
         }
    }
    }
    }
    }
Was it helpful?

Solution

solved the problem the answer is

     List<Point> points = new List<Point>();
 for (int i = 0; i < points.Count; i++)
        {               
            Point point = points[i];
            Point pointx = points[i];
            Color pixelColor = img.SetPixel(point.X, pointx.Y);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top