como dibujar un pixel en csharp
Publicado por juan daniel (5 intervenciones) el 30/08/2014 22:05:38
hola tengo que hacer una especie de paint en c# pero mi maestro lo primero que me pide es dibujar un pixel dando click en un boton y dibujarlo en un picturebox. Solo tengo algo de codigo que creo k me servira pero no se bien como usarlo.
o
Agradeciara mucho su ayuda porfavor.
1
2
3
4
5
Bitmap bm=new Bitmap(1,1);
bm.SetPixel(0,0,Color.Red);
e.Graphics.DrawImageUnscaled(bm,<xPosition>,<yPosition>);
o
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
private void SetPixel_Example(PaintEventArgs e)
{
// Create a Bitmap object from a file.
Bitmap myBitmap = new Bitmap("Grapes.jpg");
// Draw myBitmap to the screen.
e.Graphics.DrawImage(myBitmap, 0, 0, myBitmap.Width,
myBitmap.Height);
// Set each pixel in myBitmap to black.
for (int Xcount = 0; Xcount < myBitmap.Width; Xcount++)
{
for (int Ycount = 0; Ycount < myBitmap.Height; Ycount++)
{
myBitmap.SetPixel(Xcount, Ycount, Color.Black);
}
}
// Draw myBitmap to the screen again.
e.Graphics.DrawImage(myBitmap, myBitmap.Width, 0,
myBitmap.Width, myBitmap.Height);
}
Agradeciara mucho su ayuda porfavor.
Valora esta pregunta


0