public bool Update() { // adjust the size if(step == 1) { if (dimensionsDialog == null && !dataAccess.GuiThread.WaitsToInvoke) dataAccess.GuiThread.Invoke(OpenDimensionsDialog); if (!dataAccess.GuiThread.WaitsToInvoke) { if (dimensionsDialog.Response == Gtk.ResponseType.Cancel) { dimensionsDialog.Destroy(); dimensionsDialog = null; return false; } if (dimensionsDialog.Response == Gtk.ResponseType.Ok) { width = dimensionsDialog.InputWidth; height = dimensionsDialog.InputHeight; dimensionsDialog.Destroy(); dimensionsDialog = null; step = 2; } } } // select a path where to save if(step == 2) { if(sfw == null && !dataAccess.GuiThread.WaitsToInvoke) dataAccess.GuiThread.Invoke(OpenFileBrowser); if(!dataAccess.GuiThread.IsBlockedByDialog) { fileName = sfw.SelectedPath; sfw.Destroy(); sfw = null; if (fileName == null) return false; step = 3; } } // render the image and size if (step == 3) { // setup progress bar dataAccess.GuiThread.Invoke(StartProgressBar); while (progressBar == null) ; // wait until the bar is setup progressBar.TotalSteps = editData.Collage.Images.Count + 2; Rectangle dimensions = new Rectangle(0, 0, width, height); Texture2D render = Render(dimensions, width, height); // correct alpha progressBar.StepUp("correct alpha"); Color[] colors = new Color[width * height]; render.GetData<Color>(colors); for (int i = 0; i < colors.Length; i++) { colors[i].A = 255; } render.SetData<Color>(colors); colors = null; GC.Collect(); System.Drawing.Bitmap bitmap = Utils.ToBitmap(render); progressBar.StepUp("Save"); bitmap.Save(fileName); bitmap.Dispose(); render.Dispose(); GC.Collect(); progressBar.Destroy(); step = 4; } return step < 4; }
public void OpenFileBrowser() { sfw = new SaveFileWindow(); sfw.OpenDialog(FileTypes.JPG, FileTypes.PNG, FileTypes.BMP); }