Question how to do set pixel using graphics object of picturebox ?

thippu

Active member
Joined
Mar 6, 2019
Messages
27
Location
Bangalore
Programming Experience
Beginner
Hi,
1.I have list of points from the another bitmap(pixels locations actually)

2.I have Graphics object of picture box

3.I want change the pixels color of graphics object using list of points, How to do this?.
 
Last edited:

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
2,286
Location
Sydney, Australia
Programming Experience
10+
Pixel colours of what? Handling the Paint event of a PictureBox allows you to draw onto the control. That has no direct effect on the Image object displayed in the control, although it will be drawn over that Image. Are you saying that you want to change the Image or draw something over the Image? If the latter, are the pixel locations relative to the control or the Image, because there may not be a 1:1 correspondence?
 

thippu

Active member
Joined
Mar 6, 2019
Messages
27
Location
Bangalore
Programming Experience
Beginner
Thanks for the reply.
I did like this it is working for me.
C#:
Bitmap bmp=new Bitmap(640,480,e);// 'e' is a Graphics object of picturebox
for(Point p in listofpoints)
{
    bmp.SetPixel(p.X,p.Y,Color.FromArgb(127,255,255,0))
}
e.DrawImage(bmp,0,0);
 
Top Bottom