void BitmapUpdate(Size CurrentSize) { // release graphics if (HUDGraphics != null) { HUDGraphics.Dispose(); } if (GraphicAndCurvesGraphics != null) { GraphicAndCurvesGraphics.Dispose(); } if (PictureBoxGraphics != null) { PictureBoxGraphics.Dispose(); } // release bitmaps if (HUDBitmap != null) { HUDBitmap.Dispose(); } if (GraphicAndCurvesBitmap != null) { GraphicAndCurvesBitmap.Dispose(); } if (Image != null) { Image.Dispose(); } // allocate new bitmap if (CurrentSize.Width > 0 && CurrentSize.Height > 0) { HUDBitmap = new Bitmap(CurrentSize.Width, CurrentSize.Height); GraphicAndCurvesBitmap = new Bitmap(CurrentSize.Width, CurrentSize.Height); Image = new Bitmap(CurrentSize.Width, CurrentSize.Height); } else { HUDBitmap = new Bitmap(1, 1); GraphicAndCurvesBitmap = new Bitmap(1, 1); Image = new Bitmap(1, 1); } // create new graphics HUDGraphics = Graphics.FromImage(HUDBitmap); GraphicAndCurvesGraphics = Graphics.FromImage(GraphicAndCurvesBitmap); PictureBoxGraphics = Graphics.FromImage(Image); }
public void SavePicture() { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Fichiers image (*.png)|*.png|Tous les fichiers (*.*)|*.*"; dialog.FileName = "SnaSharpSpectrum.png"; if (dialog.ShowDialog() == DialogResult.OK) { /* * PictureBoxBitmap.Dispose(); * PictureBoxBitmap = new Bitmap(2000,2000); * DrawCurveCollection(CurvesList); * PictureBoxBitmap.Save(dialog.FileName, ImageFormat.Png); * PictureBoxBitmap.Dispose(); * PictureBoxBitmap = new Bitmap(Size.Width, Size.Height); * Image = PictureBoxBitmap; */ GraphicAndCurvesBitmap.Save(dialog.FileName, ImageFormat.Png); } }