Get Pixel Color and Pixel Position

inkedGFX

Well-known member
Joined
Feb 2, 2013
Messages
142
Programming Experience
Beginner
I need a little help with getting each pixel color from a image and adding it to a list<Color> ...and get that pixels position and add it to a list<Position>.

then I want to redraw a specific pixel color and position in a picturebox.

below is the code I have so far....I believe this gets all the pixles and all the positions of the pixles.....im not sure how to get what I have to draw a specific color and position to a picturebox......
any help would be appreciated

 
for (int x = 0; x < newBitmap.Width; x++)            {
                for (int y = 0; y < newBitmap.Height; y++)
                {
                    Color pixelColor = newBitmap.GetPixel(x, y);
                    colorP.Add(pixelColor);
                    pixelPos.Add(x);
                    pixelPos.Add(y);
                }
            }


Thank You
InkedGFX
 

inkedGFX

Well-known member
Joined
Feb 2, 2013
Messages
142
Programming Experience
Beginner
I added a little code...which is on the right track...except it doesnt get the pixel position.......this will draw the color on the whole picturebox.....

  Bitmap myBitmap = new Bitmap(picOriginal.Image);           
            for (int i = 0; i < colorP.Count; i++)
            {
                for (int j = 0; j < pixelPos.Count; j++)
                {
                    for (int k = 0; k < pixelPos.Count; k++)
                    {
                        Color c = Color.FromArgb(198, 0, 53);


                        if (c == colorP[i])
                        {
                            
                            myBitmap.SetPixel(pixelPos[j], pixelPos[k], colorP[i]);
                            picColor1.Image = myBitmap;
                            picColor1.Update();
                        }
                    }
                }
            }


Thank You for any Help!

InkedGFX
 

Latest posts

Top Bottom