private void trkEffects_Scroll(object sender, EventArgs e) { if (this.selectedImage == null || this.tempImage == null) { return; } Bitmap imgCopy = tempImage; Bitmap oldImg = this.selectedImage; if (selectedEffect == SelectedEffect.Brightness) { this.selectedImage = Effects.Brightness(imgCopy, trkEffects.Value); } else if (selectedEffect == SelectedEffect.Contrast) { this.selectedImage = Effects.Contrast(imgCopy, trkEffects.Value); } else if (selectedEffect == SelectedEffect.Transparency) { oldTransparency = trkEffects.Value; this.selectedImage = Effects.Transparency(imgCopy, oldTransparency); } oldImg.Dispose(); oldImg = null; this.picBoxMain.Invalidate(); // Gargabge Collection System.GC.Collect(); }