protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); //release any resources that might be hanging out diffRecolor = null; auxRecolor = null; smoothRecolor = null; //dispose of all of the Bitmaps used for processing diffuseColDiffMap?.Dispose(); diffuseColDiffMap = null; auxColDiffMap?.Dispose(); auxColDiffMap = null; smoothColDiffMap?.Dispose(); smoothColDiffMap = null; //and all of the bitmaps used for loading diffuseMap?.Dispose(); //diffuse input auxMap?.Dispose(); //metal/specular input smoothMap?.Dispose(); //metal/specular input maskMap?.Dispose(); //mask diffuseMap = null; //diffuse input auxMap = null; //metal/specular input smoothMap = null; //metal/specular input maskMap = null; //mask //WPF image controls have no dispose method... //trigger GC just to clean up as much as possible System.GC.Collect(); }
private void generateFinished() { if (diffRecolor != null) { //diffuseColDiffMap = (DirectBitmap)generatorDiff.coloredDiff; //diffuseColDiffImage = ImageTools.BitmapToBitmapImage(diffuseColDiffMap.Bitmap); } if (auxRecolor != null) { //auxColDiffMap = (DirectBitmap)generatorAux.coloredDiff; //auxColDiffImage = ImageTools.BitmapToBitmapImage(auxColDiffMap.Bitmap); } if (smoothRecolor != null) { //smoothColDiffMap = (DirectBitmap)generatorSmooth.coloredDiff; //smoothColDiffImage = ImageTools.BitmapToBitmapImage(smoothColDiffMap.Bitmap); } diffRecolor = null; auxRecolor = null; smoothRecolor = null; //dispose of all of the Bitmaps used for processing diffuseColDiffMap?.Dispose(); diffuseColDiffMap = null; auxColDiffMap?.Dispose(); auxColDiffMap = null; smoothColDiffMap?.Dispose(); smoothColDiffMap = null; updatePreview(); }