Re: Drawing in a PictureBox
It really depends exactly what you want to do with them. Either way I think you will be using GDI+ but it might be better to draw onto an Image and display that in the PictureBox or it might be better to draw on the PictureBox itself.
Basically, you want to get a Graphics object and call one of its Draw methods; in your case probably DrawRectangle. To draw on an Image you'd call Graphics.FromImage and to draw on a PictureBox you'd handle the Paint event and use e.Graphics.
Re: Drawing in a PictureBox
Would you be able to give me an example by any chance?
As for what I want to do with them I'll process the cellular automata (which is basically a large multi-dimensional array of 1's and 0's) then render each of those values as a pixel of the specified colour. Once it's done then the control will allow saving of the image etc.
Re: Drawing in a PictureBox
Code:
Bitmap bmp = new Bitmap(100, 100);
int x, y;
for (x = 0; x < bmp.Width; x++)
{
for (y = 0; y < bmp.Height; y++)
{
Color pixelColor = bmp.GetPixel(x, y);
Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
bmp.SetPixel(x, y, newColor);
}
}
pictureBox1.Image = bmp;
Just change the loops to loop through your array dimensions instead of the bitmap. And set the Bitmaps x and y in the constructor to the appropriate dimenional size of the array