I have a PictureBox called map and I draw graphics onto it
map.CreateGraphics().FillRectangle(Brushes.Black, x+xx, y+yy, 1, 1);
It works absolutely fine, it draws the pixels, but when I attempt to save
map.Image.Save(@"C:\Users\Skye\Pictures\!Access\Map\map" + DateTime.Now.ToString("yyMMddHmmss") + ".png");
Edit: I have tried various saving methods ImageFormat.Bmp/ImageFormat.Png/etc
It brings up an error
An unhandled exception of type 'System.NullReferenceException' occurred in Terrain Genorator.exe
Additional information: Object reference not set to an instance of an object.
In Autos it says
map.Image null
or
Found the solution with thanks to @valter
Make in Bitmap, make picturebox show the image, save either bitmap or picturebox.
Bitmap mapImage;
mapImage = new Bitmap(pWidth, pHeight);
mapImage.SetPixel(x + xx, y + yy, Color.Black);
map.Image = mapImage;
map.Image.Save(@"C:\Users\Skye\Pictures\!Access\Map\" + DateTime.Now.ToString("yyMMddHmmss") + ".png");