diff --git a/Greenshot/Configuration/AppConfig.cs b/Greenshot/Configuration/AppConfig.cs index 3906bebf5..054875d1c 100644 --- a/Greenshot/Configuration/AppConfig.cs +++ b/Greenshot/Configuration/AppConfig.cs @@ -158,7 +158,7 @@ namespace Greenshot.Configuration { coreConfiguration.OutputFileIncrementingNumber = unchecked((uint)appConfig.Output_File_IncrementingNumber); coreConfiguration.OutputFileJpegQuality = appConfig.Output_File_JpegQuality; coreConfiguration.OutputFilePath = appConfig.Output_File_Path; - coreConfiguration.OutputFilePromptJpegQuality = (bool)appConfig.Output_File_PromptJpegQuality; + coreConfiguration.OutputFilePromptQuality = (bool)appConfig.Output_File_PromptJpegQuality; coreConfiguration.Language = appConfig.Ui_Language; coreConfiguration.PlayCameraSound = (bool)appConfig.Ui_Effects_CameraSound; coreConfiguration.CaptureMousepointer = (bool)appConfig.Capture_Mousepointer; diff --git a/Greenshot/Configuration/LanguageKeys.cs b/Greenshot/Configuration/LanguageKeys.cs index b5e012f82..7d86c3d7c 100644 --- a/Greenshot/Configuration/LanguageKeys.cs +++ b/Greenshot/Configuration/LanguageKeys.cs @@ -146,6 +146,7 @@ namespace Greenshot.Configuration { jpegqualitydialog_choosejpegquality, jpegqualitydialog_dontaskagain, jpegqualitydialog_title, + reduce_colors, print_error, printoptions_allowcenter, printoptions_allowenlarge, diff --git a/Greenshot/Destinations/EmailDestination.cs b/Greenshot/Destinations/EmailDestination.cs index 43dcfb406..8d9fe0ad9 100644 --- a/Greenshot/Destinations/EmailDestination.cs +++ b/Greenshot/Destinations/EmailDestination.cs @@ -190,7 +190,7 @@ namespace Greenshot.Destinations { string tmpFile = captureDetails.Filename; if (tmpFile == null || surface.Modified) { using (Image image = surface.GetImageForExport()) { - tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality); + tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors); } } // Create a attachment name for the image diff --git a/Greenshot/Destinations/ExcelDestination.cs b/Greenshot/Destinations/ExcelDestination.cs index 5fdb7235e..d35fdaa7b 100644 --- a/Greenshot/Destinations/ExcelDestination.cs +++ b/Greenshot/Destinations/ExcelDestination.cs @@ -114,7 +114,7 @@ namespace Greenshot.Destinations { string tmpFile = captureDetails.Filename; if (tmpFile == null || surface.Modified) { using (Image image = surface.GetImageForExport()) { - tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality); + tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors); } } if (workbookName != null) { diff --git a/Greenshot/Destinations/PowerpointDestination.cs b/Greenshot/Destinations/PowerpointDestination.cs index 963beab72..93b3bbcf6 100644 --- a/Greenshot/Destinations/PowerpointDestination.cs +++ b/Greenshot/Destinations/PowerpointDestination.cs @@ -116,7 +116,7 @@ namespace Greenshot.Destinations { Size imageSize = Size.Empty; if (tmpFile == null || surface.Modified) { using (Image image = surface.GetImageForExport()) { - tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality); + tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors); imageSize = image.Size; } } diff --git a/Greenshot/Destinations/WordDestination.cs b/Greenshot/Destinations/WordDestination.cs index 8d0b11927..a374cedbf 100644 --- a/Greenshot/Destinations/WordDestination.cs +++ b/Greenshot/Destinations/WordDestination.cs @@ -116,7 +116,7 @@ namespace Greenshot.Destinations { string tmpFile = captureDetails.Filename; if (tmpFile == null || surface.Modified) { using (Image image = surface.GetImageForExport()) { - tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality); + tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors); } } if (documentCaption != null) { diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs index b599169b5..7454728a0 100644 --- a/Greenshot/Forms/ImageEditorForm.cs +++ b/Greenshot/Forms/ImageEditorForm.cs @@ -497,9 +497,9 @@ namespace Greenshot { get { return surface.CaptureDetails; } } - public void SaveToStream(Stream stream, OutputFormat extension, int quality) { + public void SaveToStream(Stream stream, OutputFormat extension, int quality, bool reduceColors) { using (Image image = surface.GetImageForExport()) { - ImageOutput.SaveToStream(image, stream, extension, quality); + ImageOutput.SaveToStream(image, stream, extension, quality, reduceColors); } } diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index 4224d3769..7762e0478 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -371,6 +371,7 @@ namespace Greenshot { LOG.Debug("Data received, Command = " + command.Key + ", Data: " + command.Value); switch(command.Key) { case CommandEnum.Exit: + LOG.Info("Exit requested"); Exit(); break; case CommandEnum.FirstLaunch: @@ -395,12 +396,14 @@ namespace Greenshot { } catch {} break; case CommandEnum.ReloadConfig: + LOG.Info("Reload requested"); try { IniConfig.Reload(); ReloadConfiguration(null, null); } catch {} break; case CommandEnum.OpenFile: + LOG.InfoFormat("Open file requested: {0}", filename); string filename = command.Value; if (File.Exists(filename)) { BeginInvoke((MethodInvoker)delegate { diff --git a/Greenshot/Forms/JpegQualityDialog.Designer.cs b/Greenshot/Forms/QualityDialog.Designer.cs similarity index 81% rename from Greenshot/Forms/JpegQualityDialog.Designer.cs rename to Greenshot/Forms/QualityDialog.Designer.cs index 721d6bd28..0053918df 100644 --- a/Greenshot/Forms/JpegQualityDialog.Designer.cs +++ b/Greenshot/Forms/QualityDialog.Designer.cs @@ -19,7 +19,7 @@ * along with this program. If not, see . */ namespace Greenshot { - partial class JpegQualityDialog : System.Windows.Forms.Form { + partial class QualityDialog : System.Windows.Forms.Form { /// /// Designer variable used to keep track of non-visual components. /// @@ -46,25 +46,27 @@ namespace Greenshot { /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QualityDialog)); this.label_choosejpegquality = new System.Windows.Forms.Label(); this.textBoxJpegQuality = new System.Windows.Forms.TextBox(); this.trackBarJpegQuality = new System.Windows.Forms.TrackBar(); this.checkbox_dontaskagain = new System.Windows.Forms.CheckBox(); this.button_ok = new System.Windows.Forms.Button(); + this.checkBox_reduceColors = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.trackBarJpegQuality)).BeginInit(); this.SuspendLayout(); // // label_choosejpegquality // - this.label_choosejpegquality.Location = new System.Drawing.Point(12, 9); + this.label_choosejpegquality.Location = new System.Drawing.Point(12, 31); this.label_choosejpegquality.Name = "label_choosejpegquality"; - this.label_choosejpegquality.Size = new System.Drawing.Size(268, 32); + this.label_choosejpegquality.Size = new System.Drawing.Size(268, 35); this.label_choosejpegquality.TabIndex = 15; this.label_choosejpegquality.Text = "Choose JPEG Quality"; // // textBoxJpegQuality // - this.textBoxJpegQuality.Location = new System.Drawing.Point(245, 44); + this.textBoxJpegQuality.Location = new System.Drawing.Point(245, 69); this.textBoxJpegQuality.Name = "textBoxJpegQuality"; this.textBoxJpegQuality.ReadOnly = true; this.textBoxJpegQuality.Size = new System.Drawing.Size(35, 20); @@ -74,7 +76,7 @@ namespace Greenshot { // trackBarJpegQuality // this.trackBarJpegQuality.LargeChange = 10; - this.trackBarJpegQuality.Location = new System.Drawing.Point(12, 44); + this.trackBarJpegQuality.Location = new System.Drawing.Point(12, 69); this.trackBarJpegQuality.Maximum = 100; this.trackBarJpegQuality.Name = "trackBarJpegQuality"; this.trackBarJpegQuality.Size = new System.Drawing.Size(233, 45); @@ -86,9 +88,9 @@ namespace Greenshot { // this.checkbox_dontaskagain.CheckAlign = System.Drawing.ContentAlignment.TopLeft; this.checkbox_dontaskagain.ImageAlign = System.Drawing.ContentAlignment.TopLeft; - this.checkbox_dontaskagain.Location = new System.Drawing.Point(12, 81); + this.checkbox_dontaskagain.Location = new System.Drawing.Point(12, 106); this.checkbox_dontaskagain.Name = "checkbox_dontaskagain"; - this.checkbox_dontaskagain.Size = new System.Drawing.Size(268, 39); + this.checkbox_dontaskagain.Size = new System.Drawing.Size(268, 37); this.checkbox_dontaskagain.TabIndex = 17; this.checkbox_dontaskagain.Text = "Save as default quality and do not ask again."; this.checkbox_dontaskagain.TextAlign = System.Drawing.ContentAlignment.TopLeft; @@ -97,7 +99,7 @@ namespace Greenshot { // button_ok // this.button_ok.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.button_ok.Location = new System.Drawing.Point(205, 126); + this.button_ok.Location = new System.Drawing.Point(205, 149); this.button_ok.Name = "button_ok"; this.button_ok.Size = new System.Drawing.Size(75, 23); this.button_ok.TabIndex = 18; @@ -105,17 +107,28 @@ namespace Greenshot { this.button_ok.UseVisualStyleBackColor = true; this.button_ok.Click += new System.EventHandler(this.Button_okClick); // + // checkBox_reduceColors + // + this.checkBox_reduceColors.AutoSize = true; + this.checkBox_reduceColors.Location = new System.Drawing.Point(12, 11); + this.checkBox_reduceColors.Name = "checkBox_reduceColors"; + this.checkBox_reduceColors.Size = new System.Drawing.Size(95, 17); + this.checkBox_reduceColors.TabIndex = 19; + this.checkBox_reduceColors.Text = "Reduce colors"; + this.checkBox_reduceColors.UseVisualStyleBackColor = true; + // // JpegQualityDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.ClientSize = new System.Drawing.Size(299, 161); + this.ClientSize = new System.Drawing.Size(299, 184); + this.Controls.Add(this.checkBox_reduceColors); this.Controls.Add(this.button_ok); this.Controls.Add(this.checkbox_dontaskagain); this.Controls.Add(this.label_choosejpegquality); this.Controls.Add(this.textBoxJpegQuality); this.Controls.Add(this.trackBarJpegQuality); - this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "JpegQualityDialog"; @@ -124,11 +137,13 @@ namespace Greenshot { ((System.ComponentModel.ISupportInitialize)(this.trackBarJpegQuality)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); + } private System.Windows.Forms.Button button_ok; private System.Windows.Forms.CheckBox checkbox_dontaskagain; private System.Windows.Forms.TrackBar trackBarJpegQuality; private System.Windows.Forms.TextBox textBoxJpegQuality; private System.Windows.Forms.Label label_choosejpegquality; + private System.Windows.Forms.CheckBox checkBox_reduceColors; } } diff --git a/Greenshot/Forms/JpegQualityDialog.cs b/Greenshot/Forms/QualityDialog.cs similarity index 78% rename from Greenshot/Forms/JpegQualityDialog.cs rename to Greenshot/Forms/QualityDialog.cs index a2af3b3f7..a30ba6f1c 100644 --- a/Greenshot/Forms/JpegQualityDialog.cs +++ b/Greenshot/Forms/QualityDialog.cs @@ -28,28 +28,34 @@ namespace Greenshot { /// /// Description of JpegQualityDialog. /// - public partial class JpegQualityDialog : Form { + public partial class QualityDialog : Form { private static CoreConfiguration conf = IniConfig.GetIniSection(); ILanguage lang; public int Quality = 0; - public JpegQualityDialog() { + public bool ReduceColors = false; + public QualityDialog(bool isJPG) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); lang = Language.GetInstance(); + this.checkBox_reduceColors.Checked = conf.OutputFileReduceColors; + this.trackBarJpegQuality.Enabled = isJPG; this.trackBarJpegQuality.Value = conf.OutputFileJpegQuality; + this.textBoxJpegQuality.Enabled = isJPG; this.textBoxJpegQuality.Text = conf.OutputFileJpegQuality.ToString(); UpdateUI(); + WindowDetails.ToForeground(Handle); } - void Button_okClick(object sender, System.EventArgs e) { Quality = this.trackBarJpegQuality.Value; + ReduceColors = checkBox_reduceColors.Checked; if(this.checkbox_dontaskagain.Checked) { conf.OutputFileJpegQuality = Quality; - conf.OutputFilePromptJpegQuality = false; + conf.OutputFilePromptQuality = false; + conf.OutputFileReduceColors = ReduceColors; IniConfig.Save(); } } @@ -58,6 +64,7 @@ namespace Greenshot { this.Text = lang.GetString(LangKey.jpegqualitydialog_title); this.label_choosejpegquality.Text = lang.GetString(LangKey.jpegqualitydialog_choosejpegquality); this.checkbox_dontaskagain.Text = lang.GetString(LangKey.jpegqualitydialog_dontaskagain); + this.checkBox_reduceColors.Text = lang.GetString(LangKey.reduce_colors); } void TrackBarJpegQualityScroll(object sender, System.EventArgs e) { diff --git a/Greenshot/Forms/SettingsForm.Designer.cs b/Greenshot/Forms/SettingsForm.Designer.cs index 4f28d028e..c46735af1 100644 --- a/Greenshot/Forms/SettingsForm.Designer.cs +++ b/Greenshot/Forms/SettingsForm.Designer.cs @@ -117,6 +117,7 @@ namespace Greenshot { this.groupbox_plugins = new System.Windows.Forms.GroupBox(); this.listview_plugins = new System.Windows.Forms.ListView(); this.button_pluginconfigure = new System.Windows.Forms.Button(); + this.tab_destinations = new System.Windows.Forms.TabPage(); this.groupbox_preferredfilesettings.SuspendLayout(); this.groupbox_applicationsettings.SuspendLayout(); this.groupbox_jpegsettings.SuspendLayout(); @@ -246,7 +247,7 @@ namespace Greenshot { this.groupbox_preferredfilesettings.Controls.Add(this.textbox_storagelocation); this.groupbox_preferredfilesettings.Controls.Add(this.textbox_screenshotname); this.groupbox_preferredfilesettings.Controls.Add(this.label_screenshotname); - this.groupbox_preferredfilesettings.Location = new System.Drawing.Point(2, 106); + this.groupbox_preferredfilesettings.Location = new System.Drawing.Point(2, 6); this.groupbox_preferredfilesettings.Name = "groupbox_preferredfilesettings"; this.groupbox_preferredfilesettings.Size = new System.Drawing.Size(412, 122); this.groupbox_preferredfilesettings.TabIndex = 13; @@ -299,7 +300,7 @@ namespace Greenshot { this.groupbox_jpegsettings.Controls.Add(this.label_jpegquality); this.groupbox_jpegsettings.Controls.Add(this.textBoxJpegQuality); this.groupbox_jpegsettings.Controls.Add(this.trackBarJpegQuality); - this.groupbox_jpegsettings.Location = new System.Drawing.Point(2, 234); + this.groupbox_jpegsettings.Location = new System.Drawing.Point(2, 156); this.groupbox_jpegsettings.Name = "groupbox_jpegsettings"; this.groupbox_jpegsettings.Size = new System.Drawing.Size(412, 83); this.groupbox_jpegsettings.TabIndex = 14; @@ -338,7 +339,7 @@ namespace Greenshot { this.trackBarJpegQuality.Location = new System.Drawing.Point(138, 21); this.trackBarJpegQuality.Maximum = 100; this.trackBarJpegQuality.Name = "trackBarJpegQuality"; - this.trackBarJpegQuality.Size = new System.Drawing.Size(233, 42); + this.trackBarJpegQuality.Size = new System.Drawing.Size(233, 45); this.trackBarJpegQuality.TabIndex = 0; this.trackBarJpegQuality.TickFrequency = 10; this.trackBarJpegQuality.Scroll += new System.EventHandler(this.TrackBarJpegQualityScroll); @@ -348,7 +349,7 @@ namespace Greenshot { this.groupbox_destination.Controls.Add(this.checkedDestinationsListBox); this.groupbox_destination.Location = new System.Drawing.Point(2, 6); this.groupbox_destination.Name = "groupbox_destination"; - this.groupbox_destination.Size = new System.Drawing.Size(412, 94); + this.groupbox_destination.Size = new System.Drawing.Size(412, 294); this.groupbox_destination.TabIndex = 16; this.groupbox_destination.TabStop = false; this.groupbox_destination.Text = "Screenshot Destination"; @@ -359,7 +360,7 @@ namespace Greenshot { this.checkedDestinationsListBox.Location = new System.Drawing.Point(5, 20); this.checkedDestinationsListBox.Name = "checkedDestinationsListBox"; this.checkedDestinationsListBox.ScrollAlwaysVisible = true; - this.checkedDestinationsListBox.Size = new System.Drawing.Size(401, 64); + this.checkedDestinationsListBox.Size = new System.Drawing.Size(401, 284); this.checkedDestinationsListBox.TabIndex = 0; this.checkedDestinationsListBox.SelectedValueChanged += new System.EventHandler(this.DestinationsCheckStateChanged); // @@ -368,6 +369,7 @@ namespace Greenshot { this.tabcontrol.Controls.Add(this.tab_general); this.tabcontrol.Controls.Add(this.tab_capture); this.tabcontrol.Controls.Add(this.tab_output); + this.tabcontrol.Controls.Add(this.tab_destinations); this.tabcontrol.Controls.Add(this.tab_printer); this.tabcontrol.Location = new System.Drawing.Point(12, 13); this.tabcontrol.Name = "tabcontrol"; @@ -672,16 +674,16 @@ namespace Greenshot { // numericUpDownWaitTime // this.numericUpDownWaitTime.Increment = new decimal(new int[] { - 100, - 0, - 0, - 0}); + 100, + 0, + 0, + 0}); this.numericUpDownWaitTime.Location = new System.Drawing.Point(11, 69); this.numericUpDownWaitTime.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); + 10000, + 0, + 0, + 0}); this.numericUpDownWaitTime.Name = "numericUpDownWaitTime"; this.numericUpDownWaitTime.Size = new System.Drawing.Size(57, 20); this.numericUpDownWaitTime.TabIndex = 24; @@ -698,9 +700,8 @@ namespace Greenshot { // tab_output // this.tab_output.BackColor = System.Drawing.Color.Transparent; - this.tab_output.Controls.Add(this.groupbox_destination); - this.tab_output.Controls.Add(this.groupbox_jpegsettings); this.tab_output.Controls.Add(this.groupbox_preferredfilesettings); + this.tab_output.Controls.Add(this.groupbox_jpegsettings); this.tab_output.Location = new System.Drawing.Point(4, 22); this.tab_output.Name = "tab_output"; this.tab_output.Padding = new System.Windows.Forms.Padding(3); @@ -720,6 +721,16 @@ namespace Greenshot { this.tab_printer.Text = "Printer"; this.tab_printer.UseVisualStyleBackColor = true; // + // tab_destinations + // + this.tab_destinations.Location = new System.Drawing.Point(4, 22); + this.tab_destinations.Controls.Add(this.groupbox_destination); + this.tab_destinations.Name = "tab_destinations"; + this.tab_destinations.Size = new System.Drawing.Size(423, 320); + this.tab_destinations.TabIndex = 4; + this.tab_destinations.Text = "Destinations"; + this.tab_destinations.UseVisualStyleBackColor = true; + // // groupbox_printoptions // this.groupbox_printoptions.Controls.Add(this.checkboxPrintInverted); @@ -829,9 +840,9 @@ namespace Greenshot { // // groupbox_plugins // - this.groupbox_plugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.groupbox_plugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.groupbox_plugins.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.groupbox_plugins.Controls.Add(this.listview_plugins); this.groupbox_plugins.Controls.Add(this.button_pluginconfigure); @@ -882,8 +893,8 @@ namespace Greenshot { this.MinimizeBox = false; this.Name = "SettingsForm"; this.Text = "SettingsForm"; - this.Shown += new System.EventHandler(this.SettingsFormShown); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SettingsFormFormClosing); + this.Shown += new System.EventHandler(this.SettingsFormShown); this.groupbox_preferredfilesettings.ResumeLayout(false); this.groupbox_preferredfilesettings.PerformLayout(); this.groupbox_applicationsettings.ResumeLayout(false); @@ -911,6 +922,7 @@ namespace Greenshot { this.groupbox_plugins.ResumeLayout(false); this.groupbox_plugins.PerformLayout(); this.ResumeLayout(false); + } private System.Windows.Forms.CheckedListBox checkedDestinationsListBox; private System.Windows.Forms.GroupBox groupbox_editor; @@ -982,5 +994,6 @@ namespace Greenshot { private System.Windows.Forms.Button settings_okay; private System.Windows.Forms.TextBox textbox_storagelocation; private System.Windows.Forms.Label label_storagelocation; + private System.Windows.Forms.TabPage tab_destinations; } } diff --git a/Greenshot/Forms/SettingsForm.cs b/Greenshot/Forms/SettingsForm.cs index b2ef9d7ec..28b36e350 100644 --- a/Greenshot/Forms/SettingsForm.cs +++ b/Greenshot/Forms/SettingsForm.cs @@ -188,6 +188,7 @@ namespace Greenshot { this.checkbox_autostartshortcut.Text = lang.GetString(LangKey.settings_autostartshortcut); this.groupbox_destination.Text = lang.GetString(LangKey.settings_destination); + this.tab_destinations.Text = lang.GetString(LangKey.settings_destination); this.groupbox_preferredfilesettings.Text = lang.GetString(LangKey.settings_preferredfilesettings); @@ -270,7 +271,7 @@ namespace Greenshot { checkbox_copypathtoclipboard.Checked = coreConfiguration.OutputFileCopyPathToClipboard; trackBarJpegQuality.Value = coreConfiguration.OutputFileJpegQuality; textBoxJpegQuality.Text = coreConfiguration.OutputFileJpegQuality+"%"; - checkbox_alwaysshowjpegqualitydialog.Checked = coreConfiguration.OutputFilePromptJpegQuality; + checkbox_alwaysshowjpegqualitydialog.Checked = coreConfiguration.OutputFilePromptQuality; checkbox_playsound.Checked = coreConfiguration.PlayCameraSound; checkedDestinationsListBox.Items.Clear(); @@ -315,7 +316,10 @@ namespace Greenshot { private void SaveSettings() { if (combobox_language.SelectedItem != null) { - coreConfiguration.Language = combobox_language.SelectedValue.ToString(); + string newLang = combobox_language.SelectedValue.ToString(); + if (!string.IsNullOrEmpty(newLang)) { + coreConfiguration.Language = combobox_language.SelectedValue.ToString(); + } } coreConfiguration.WindowCaptureMode = GetSelected(combobox_window_capture_mode); @@ -331,7 +335,7 @@ namespace Greenshot { coreConfiguration.OutputFileCopyPathToClipboard = checkbox_copypathtoclipboard.Checked; coreConfiguration.OutputFileJpegQuality = trackBarJpegQuality.Value; - coreConfiguration.OutputFilePromptJpegQuality = checkbox_alwaysshowjpegqualitydialog.Checked; + coreConfiguration.OutputFilePromptQuality = checkbox_alwaysshowjpegqualitydialog.Checked; coreConfiguration.PlayCameraSound = checkbox_playsound.Checked; List destinations = new List(); diff --git a/Greenshot/Helpers/ClipboardHelper.cs b/Greenshot/Helpers/ClipboardHelper.cs index ed6d92669..06ae212b2 100644 --- a/Greenshot/Helpers/ClipboardHelper.cs +++ b/Greenshot/Helpers/ClipboardHelper.cs @@ -375,7 +375,7 @@ EndSelection:<<<<<<<4 // Set the HTML if (config.ClipboardFormats.Contains(ClipboardFormat.HTML)) { - string tmpFile = ImageOutput.SaveToTmpFile(image, OutputFormat.png, config.OutputFileJpegQuality); + string tmpFile = ImageOutput.SaveToTmpFile(image, OutputFormat.png, config.OutputFileJpegQuality, config.OutputFileReduceColors); string html = getHTMLString(image, tmpFile); ido.SetText(html, TextDataFormat.Html); } else if (config.ClipboardFormats.Contains(ClipboardFormat.HTMLDATAURL)) { diff --git a/Greenshot/Helpers/ImageOutput.cs b/Greenshot/Helpers/ImageOutput.cs index 2ccf5c74f..8843de906 100644 --- a/Greenshot/Helpers/ImageOutput.cs +++ b/Greenshot/Helpers/ImageOutput.cs @@ -75,7 +75,7 @@ namespace Greenshot.Helpers { /// /// Saves image to stream with specified quality /// - public static void SaveToStream(Image imageToSave, Stream stream, OutputFormat extension, int quality) { + public static void SaveToStream(Image imageToSave, Stream stream, OutputFormat extension, int quality, bool reduceColors) { ImageFormat imageFormat = null; bool disposeImage = false; @@ -101,7 +101,7 @@ namespace Greenshot.Helpers { } // If Quantizing is enable, overwrite the image to save with a 256 - color version - if (conf.OutputFileReduceColors) { + if (reduceColors) { try { LOG.Debug("Reducing colors on bitmap."); Quantizer quantizer = new OctreeQuantizer(255,8); @@ -148,7 +148,7 @@ namespace Greenshot.Helpers { /// /// Saves image to specific path with specified quality /// - public static void Save(Image image, string fullPath, bool allowOverwrite, int quality, bool copyPathToClipboard) { + public static void Save(Image image, string fullPath, bool allowOverwrite, int quality, bool reduceColors, bool copyPathToClipboard) { fullPath = FilenameHelper.MakeFQFilenameSafe(fullPath); string path = Path.GetDirectoryName(fullPath); @@ -177,7 +177,7 @@ namespace Greenshot.Helpers { LOG.DebugFormat("Saving image to {0}", fullPath); // Create the stream and call SaveToStream using (FileStream stream = new FileStream(fullPath, FileMode.Create, FileAccess.Write)) { - SaveToStream(image, stream, format, quality); + SaveToStream(image, stream, format, quality, reduceColors); } if (copyPathToClipboard) { @@ -192,7 +192,8 @@ namespace Greenshot.Helpers { /// the absolute destination path including file name /// true if overwrite is allowed, false if not public static void Save(Image img, string fullPath, bool allowOverwrite) { - int q; + int quality; + bool reduceColors = false; // Fix for bug 2912959 string extension = fullPath.Substring(fullPath.LastIndexOf(".") + 1); @@ -201,14 +202,16 @@ namespace Greenshot.Helpers { isJPG = "JPG".Equals(extension.ToUpper()) || "JPEG".Equals(extension.ToUpper()); } - if(isJPG && conf.OutputFilePromptJpegQuality) { - JpegQualityDialog jqd = new JpegQualityDialog(); - jqd.ShowDialog(); - q = jqd.Quality; + if(isJPG && conf.OutputFilePromptQuality) { + QualityDialog qualityDialog = new QualityDialog(isJPG); + qualityDialog.ShowDialog(); + quality = qualityDialog.Quality; + reduceColors = qualityDialog.ReduceColors; } else { - q = conf.OutputFileJpegQuality; + quality = conf.OutputFileJpegQuality; + reduceColors = conf.OutputFileReduceColors; } - Save(img, fullPath, allowOverwrite, q, conf.OutputFileCopyPathToClipboard); + Save(img, fullPath, allowOverwrite, quality, reduceColors, conf.OutputFileCopyPathToClipboard); } #endregion @@ -237,7 +240,7 @@ namespace Greenshot.Helpers { } #endregion - public static string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputFormat outputFormat, int quality) { + public static string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputFormat outputFormat, int quality, bool reduceColors) { string pattern = conf.OutputFileFilenamePattern; if (pattern == null || string.IsNullOrEmpty(pattern.Trim())) { pattern = "greenshot ${capturetime}"; @@ -254,7 +257,7 @@ namespace Greenshot.Helpers { // Catching any exception to prevent that the user can't write in the directory. // This is done for e.g. bugs #2974608, #2963943, #2816163, #2795317, #2789218 try { - ImageOutput.Save(image, tmpFile, true, quality, false); + ImageOutput.Save(image, tmpFile, true, quality, reduceColors, false); tmpFileCache.Add(tmpFile, tmpFile); } catch (Exception e) { // Show the problem @@ -270,7 +273,7 @@ namespace Greenshot.Helpers { /// /// /// - public static string SaveToTmpFile(Image image, OutputFormat outputFormat, int quality) { + public static string SaveToTmpFile(Image image, OutputFormat outputFormat, int quality, bool reduceColors) { string tmpFile = Path.GetRandomFileName() + "." + outputFormat.ToString(); // Prevent problems with "other characters", which could cause problems tmpFile = Regex.Replace(tmpFile, @"[^\d\w\.]", ""); @@ -278,7 +281,7 @@ namespace Greenshot.Helpers { LOG.Debug("Creating TMP File : " + tmpPath); try { - ImageOutput.Save(image, tmpPath, true, quality, false); + ImageOutput.Save(image, tmpPath, true, quality, reduceColors, false); tmpFileCache.Add(tmpPath, tmpPath); } catch (Exception) { return null; diff --git a/Greenshot/Helpers/MailHelper.cs b/Greenshot/Helpers/MailHelper.cs index 2c20c0457..eab102039 100644 --- a/Greenshot/Helpers/MailHelper.cs +++ b/Greenshot/Helpers/MailHelper.cs @@ -66,7 +66,7 @@ namespace Greenshot.Helpers { /// The image to send /// ICaptureDetails public static void SendImage(Image image, ICaptureDetails captureDetails) { - string tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality); + string tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors); if (tmpFile != null) { // Store the list of currently active windows, so we can make sure we show the email window later! diff --git a/Greenshot/Helpers/PluginHelper.cs b/Greenshot/Helpers/PluginHelper.cs index cde98ad14..3a3058495 100644 --- a/Greenshot/Helpers/PluginHelper.cs +++ b/Greenshot/Helpers/PluginHelper.cs @@ -100,16 +100,16 @@ namespace Greenshot.Helpers { } } - public void SaveToStream(Image img, Stream stream, OutputFormat extension, int quality) { - ImageOutput.SaveToStream(img, stream, extension, quality); + public void SaveToStream(Image img, Stream stream, OutputFormat extension, int quality, bool reduceColors) { + ImageOutput.SaveToStream(img, stream, extension, quality, reduceColors); } - public string SaveToTmpFile(Image img, OutputFormat outputFormat, int quality) { - return ImageOutput.SaveToTmpFile(img, outputFormat, quality); + public string SaveToTmpFile(Image img, OutputFormat outputFormat, int quality, bool reduceColors) { + return ImageOutput.SaveToTmpFile(img, outputFormat, quality, reduceColors); } - - public string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputFormat outputFormat, int quality) { - return ImageOutput.SaveNamedTmpFile(image, captureDetails, outputFormat, quality); + + public string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputFormat outputFormat, int quality, bool reduceColors) { + return ImageOutput.SaveNamedTmpFile(image, captureDetails, outputFormat, quality, reduceColors); } public string GetFilename(OutputFormat format, ICaptureDetails captureDetails) { diff --git a/Greenshot/Languages/language-en-US.xml b/Greenshot/Languages/language-en-US.xml index aa8633c22..0d8d393af 100644 --- a/Greenshot/Languages/language-en-US.xml +++ b/Greenshot/Languages/language-en-US.xml @@ -197,15 +197,18 @@ Details about the GNU General Public License: Show JPEG quality dialog every time a JPEG image is saved - Greenshot JPEG quality + Greenshot quality Please choose the quality for your JPEG image. - Save as default JPEG quality and do not ask again + Save as default quality and do not ask again - + + Reduce the amount of colors to 256 (can have impact on quality!) + + Line color diff --git a/GreenshotPlugin/Core/CoreConfiguration.cs b/GreenshotPlugin/Core/CoreConfiguration.cs index 27e450be2..bd1f31397 100644 --- a/GreenshotPlugin/Core/CoreConfiguration.cs +++ b/GreenshotPlugin/Core/CoreConfiguration.cs @@ -105,8 +105,8 @@ namespace GreenshotPlugin.Core { [IniProperty("OutputFileJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")] public int OutputFileJpegQuality; - [IniProperty("OutputFilePromptJpegQuality", Description="Ask for the JPEQ quality before saving?", DefaultValue="false")] - public bool OutputFilePromptJpegQuality; + [IniProperty("OutputFilePromptQuality", Description="Ask for the quality before saving?", DefaultValue="false")] + public bool OutputFilePromptQuality; [IniProperty("OutputFileIncrementingNumber", Description="The number for the ${NUM} in the filename pattern, is increased automatically after each save.", DefaultValue="1")] public uint OutputFileIncrementingNumber; diff --git a/GreenshotPlugin/IniFile/IniConfig.cs b/GreenshotPlugin/IniFile/IniConfig.cs index bb8659680..9a5eb43ea 100644 --- a/GreenshotPlugin/IniFile/IniConfig.cs +++ b/GreenshotPlugin/IniFile/IniConfig.cs @@ -131,7 +131,7 @@ namespace Greenshot.IniFile { private static void ConfigFileChanged(object source, FileSystemEventArgs e) { string iniLocation = CreateIniLocation(configName + INI_EXTENSION); if (iniLocation.Equals(e.FullPath)) { - //LOG.InfoFormat("Config file {0} was changed, reloading", e.FullPath); + LOG.InfoFormat("Config file {0} was changed, reloading", e.FullPath); // Try to reread the configuration int retries = 10; diff --git a/GreenshotPlugin/Interfaces/Forms/ImageEditor.cs b/GreenshotPlugin/Interfaces/Forms/ImageEditor.cs index b7b0f58c9..80cf93d4f 100644 --- a/GreenshotPlugin/Interfaces/Forms/ImageEditor.cs +++ b/GreenshotPlugin/Interfaces/Forms/ImageEditor.cs @@ -51,7 +51,8 @@ namespace Greenshot.Plugin { /// The stream the image is stored on /// The image type (extension), e.g. "png", "jpg", "bmp" /// Only needed for "jpg" - void SaveToStream(Stream stream, OutputFormat extension, int quality); + /// reduce the amount of colors to 256 + void SaveToStream(Stream stream, OutputFormat extension, int quality, bool reduceColors); /// /// Get the ToolStripMenuItem where plugins can place their Menu entrys diff --git a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs index f6e879636..f80121bdf 100644 --- a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs +++ b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs @@ -77,7 +77,8 @@ namespace Greenshot.Plugin { /// The Stream to save to /// The format to save with (png, jpg etc) /// Jpeg quality - void SaveToStream(Image image, Stream stream, OutputFormat format, int quality); + /// reduce the amount of colors to 256 + void SaveToStream(Image image, Stream stream, OutputFormat format, int quality, bool reduceColors); /// /// Saves the image to a temp file (random name) using the specified outputformat @@ -85,7 +86,8 @@ namespace Greenshot.Plugin { /// The Image to save /// The format to save with (png, jpg etc) /// Jpeg quality - string SaveToTmpFile(Image image, OutputFormat outputFormat, int quality); + /// reduce the amount of colors to 256 + string SaveToTmpFile(Image image, OutputFormat outputFormat, int quality, bool reduceColors); /// /// Saves the image to a temp file, but the name is build with the capture details & pattern @@ -94,7 +96,8 @@ namespace Greenshot.Plugin { /// captureDetails with the information to build the filename /// The format to save with (png, jpg etc) /// Jpeg quality - string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputFormat outputFormat, int quality); + /// reduce the amount of colors to 256 + string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputFormat outputFormat, int quality, bool reduceColors); /// /// Return a filename for the current image format (png,jpg etc) with the default file pattern diff --git a/PluginExample/SimpleOutputDestination.cs b/PluginExample/SimpleOutputDestination.cs index da5d6fadf..b9830cb4a 100644 --- a/PluginExample/SimpleOutputDestination.cs +++ b/PluginExample/SimpleOutputDestination.cs @@ -67,7 +67,7 @@ namespace PluginExample { string filePath = Path.Combine(config.OutputFilePath, file); using (FileStream stream = new FileStream(filePath, FileMode.Create)) { using (Image image = surface.GetImageForExport()) { - host.SaveToStream(image, stream, OutputFormat.png, 100); + host.SaveToStream(image, stream, OutputFormat.png, config.OutputFileJpegQuality, config.OutputFileReduceColors); } } MessageBox.Show("Saved test file to: " + filePath);