/// <summary> /// A RaisePostBackEvent. /// </summary> /// <param name="eventArgument">eventArgument</param> public new void RaisePostBackEvent(String eventArgument) { // Create the new name var tempFileName = ParentImageEditor.GetTempFileName(); var job = new ImageJob(ParentImageEditor.WorkFile); ParentImageEditor.ImageHeight = job.Image.Height; ParentImageEditor.ImageWidth = job.Image.Width; if ((ParentImageEditor.Selection.X1 > 0 && ParentImageEditor.Selection.Y1 > 0) || (ParentImageEditor.Selection.X2 > 0 && ParentImageEditor.Selection.Y2 > 0)) { float factor; float.TryParse(eventArgument, out factor); job.Zoom(ParentImageEditor.Selection.X1, ParentImageEditor.Selection.Y1, factor); PerformSave(job, tempFileName); } else { Page.RegisterStartupScript(tempFileName, "<script language='javascript'>alert('Please click on the image to set the center point.');</script>"); job.Dispose(); } OnClick(EventArgs.Empty); }
/// <summary> /// Saves image after edit works on image is done /// </summary> /// <param name="job"></param> protected virtual void PerformSave(ImageJob job, string tempFileName) { if (ParentImageEditor.DirectWrite) { job.Save(); } else { job.Save(Page.Server.MapPath(ParentImageEditor.TempDirectory) + tempFileName, FileCompression.CCITT4, 100, FileFormat.Jpeg); job.Dispose(); // Delete old temp file System.IO.File.Delete(Page.Server.MapPath(ParentImageEditor.TempURL)); ParentImageEditor.TempURL = ParentImageEditor.TempDirectory + tempFileName; } }
private void SaveClicked(object obj, EventArgs e) { // Get Parent Editor ImageEditor editor = (ImageEditor)this.Parent.Parent; string tempFile = editor.GetTempFileName(); /*string tempFile = string.Empty; * // Create the new name * if (editor.SaveURL != string.Empty) * { * tempFile = GetFileName(editor.SaveURL); * if (tempFile == string.Empty) * tempFile = editor.GetTempFileName(); * } * else * { * tempFile = editor.GetTempFileName(); * }*/ if (!editor.DirectWrite) { ActiveUp.WebControls.ImageJob job; job = new ActiveUp.WebControls.ImageJob(editor.WorkFile); //job.License = editor.License; ImageSettings blankSettings = new ImageSettings(); ImageSettings saveSettings = editor.SaveSettings; if (saveSettings != null && !blankSettings.Equals(saveSettings)) { if (saveSettings.MaxHeight != 0) { job.ResizeImage(saveSettings.MaxWidth, saveSettings.MaxWidth, saveSettings.ConstrainProportions, saveSettings.ResizeSmaller); } job.Save(Page.Server.MapPath(editor.TempDirectory) + tempFile, saveSettings.Compression, saveSettings.Quality, saveSettings.Format); } else { job.Save(Page.Server.MapPath(editor.TempDirectory) + tempFile, saveSettings.Compression, saveSettings.Quality, saveSettings.Format); } editor.OnPostProcessing(EventArgs.Empty); //job.Save(Page.Server.MapPath(editor.TempDirectory) + tempFile, editor.SaveSettings.Compression, editor.SaveSettings.Quality, editor.SaveSettings.Format); job.Dispose(); // Delete old temp file System.IO.File.Delete(Page.Server.MapPath(editor.TempURL)); editor.TempURL = editor.TempDirectory + tempFile; //editor.ImageURL = editor.TempURL; if (editor.SaveURL != string.Empty) { editor.ImageURL = editor.SaveURL; } System.IO.File.Copy(Page.Server.MapPath(editor.TempURL), Page.Server.MapPath(editor.ImageURL), true); } editor.EditorMode = ImageEditorMode.View; editor.OnSave(this, Page.Server.MapPath(editor.ImageURL)); }