• Hello and welcome to our new forums. We upgraded our forum sites to a more robust and modern system which we hope you will enjoy. Be sure to check out your profile by clicking the button on the top right and configure your preferences, signature, time zone, avatar, etc. as you wish. If you need help with using this new forum'ware try the help link on the bottom right.

    Click here to review your account now.

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,202
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