void MnuBoxClick(object sender, System.EventArgs e) { if (this.selectedImage == null) { return; } frmBF bfDLG = new frmBF(); bfDLG.BoxFilterProp = Effects.BoxFilter; DialogResult result = bfDLG.ShowDialog(); if (result == DialogResult.OK && bfDLG.BoxFilterProp.Angle != 0 && bfDLG.BoxFilterProp.BoxDepth != 0) { Effects.BoxFilter = bfDLG.BoxFilterProp; Bitmap oldImg = this.SelectedImage; this.selectedImage = Effects.Box(this.SelectedImage); oldImg.Dispose(); this.picBoxMain.Invalidate(); bfDLG.Dispose(); // Gargabge Collection System.GC.Collect(); } }