private void GenerateSpectrogram() { Image image = SpectrogramPictureBox.Image; var newImage = _spectrogram.CreateSpectrogramLine(SpectrogramPictureBox.Size, Color.White, Color.Black, true); if (newImage != null) { SpectrogramPictureBox.Image = newImage; if (image != null) { image.Dispose(); } } }