Hello to everyone,
I'm writing code for an application form with a pictureBox inside it.
All i want to do is, to load an image (in a picture box) and after that to change pixels in this image.
After searching, I've already read that SetPixel Method-in C#-can help me with that!
In PaintEvent of pictureBox the code is:
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
// Create a Bitmap object from a file.
Bitmap myBitmap = new Bitmap("D:\\...\\SP_A0195.jpg");
// Draw myBitmap to the screen.
e.Graphics.DrawImage(myBitmap,0,0,myBitmap.Width,myBitmap.Height);
// Set each pixel in myBitmap to red.
for (int Xcount = 0; Xcount < myBitmap.Width; Xcount++)
{
for (int Ycount = 0; Ycount < myBitmap.Height; Ycount++)
{
myBitmap.SetPixel(Xcount, Ycount, Color.Red);
}
}
// Draw myBitmap to the screen again.
e.Graphics.DrawImage(myBitmap,myBitmap.Width,0,myBitmap.Width,myBitmap.Height);
}
The code above doesn't work but i can not understand why...please help on how to do that.
Thank you in advance for your time!
Answers (11)
1
You can use FileSystemWatcher class to monitor files and whenever their is any change in the directory/file you can do your stuff there.
This will work without any click event.
0
Hi mohammed, you can use WindowsService Application. Please refer below links
http://www.c-sharpcorner.com/UploadFile/naresh.avari/develop-and-install-a-windows-service-in-C-Sharp/
http://www.c-sharpcorner.com/UploadFile/8a67c0/create-and-install-windows-service-step-by-step-in-C-Sharp/