I am loading a 50x50 Bitmap file and then filling it a single random color at program startup. Then save the result onto the same file and assign it to a PictureBox, but running into file write problems and "A generic error occurred in GDI+", etc.
How to do this properly so that I can continually repeat this, (open bitmap, paint it random color, save and assign to picturebox.Image)?
EDIT:
public Form1 ( )
{
InitializeComponent ( );
//Bitmap bmp = new Bitmap ( 50, 50 );
Bitmap bmp = new Bitmap ( @"C:\temp\pretty.bmp" );
Graphics g = Graphics.FromImage ( bmp );
Brush b = new SolidBrush ( Color.Red );
g.FillRectangle ( b, 0, 0, 49, 49 );
bmp.Save ( @"C:\temp\pretty.bmp" );
this.pictureBox1.Image = ( Image ) bmp.Clone ( );
//bmp.Dispose ( );
}