Added reduce colors to the quality form

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1708 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-03-19 18:29:19 +00:00
parent d824b8e893
commit 9733aa79a8
22 changed files with 131 additions and 78 deletions

View file

@ -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;

View file

@ -146,6 +146,7 @@ namespace Greenshot.Configuration {
jpegqualitydialog_choosejpegquality,
jpegqualitydialog_dontaskagain,
jpegqualitydialog_title,
reduce_colors,
print_error,
printoptions_allowcenter,
printoptions_allowenlarge,

View file

@ -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

View file

@ -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) {

View file

@ -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;
}
}

View file

@ -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) {

View file

@ -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);
}
}

View file

@ -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 {

View file

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot {
partial class JpegQualityDialog : System.Windows.Forms.Form {
partial class QualityDialog : System.Windows.Forms.Form {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
@ -46,25 +46,27 @@ namespace Greenshot {
/// </summary>
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;
}
}

View file

@ -28,28 +28,34 @@ namespace Greenshot {
/// <summary>
/// Description of JpegQualityDialog.
/// </summary>
public partial class JpegQualityDialog : Form {
public partial class QualityDialog : Form {
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
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) {

View file

@ -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);
@ -830,8 +841,8 @@ 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)));
| 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;
}
}

View file

@ -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<WindowCaptureMode>(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<string> destinations = new List<string>();

View file

@ -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)) {

View file

@ -75,7 +75,7 @@ namespace Greenshot.Helpers {
/// <summary>
/// Saves image to stream with specified quality
/// </summary>
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 {
/// <summary>
/// Saves image to specific path with specified quality
/// </summary>
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 {
/// <param name="fullPath">the absolute destination path including file name</param>
/// <param name="allowOverwrite">true if overwrite is allowed, false if not</param>
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 {
/// </summary>
/// <param name="image"></param>
/// <returns></returns>
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;

View file

@ -66,7 +66,7 @@ namespace Greenshot.Helpers {
/// <param name="image">The image to send</param>
/// <param name="captureDetails">ICaptureDetails</param>
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!

View file

@ -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) {

View file

@ -197,15 +197,18 @@ Details about the GNU General Public License:
Show JPEG quality dialog every time a JPEG image is saved
</resource>
<resource name="jpegqualitydialog_title">
Greenshot JPEG quality
Greenshot quality
</resource>
<resource name="jpegqualitydialog_choosejpegquality">
Please choose the quality for your JPEG image.
</resource>
<resource name="jpegqualitydialog_dontaskagain">
Save as default JPEG quality and do not ask again
Save as default quality and do not ask again
</resource>
<resource name="editor_forecolor">
<resource name="reduce_colors">
Reduce the amount of colors to 256 (can have impact on quality!)
</resource>
<resource name="editor_forecolor">
Line color
</resource>
<resource name="editor_backcolor">

View file

@ -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;

View file

@ -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;

View file

@ -51,7 +51,8 @@ namespace Greenshot.Plugin {
/// <param name="stream">The stream the image is stored on</param>
/// <param name="extension">The image type (extension), e.g. "png", "jpg", "bmp"</param>
/// <param name="quality">Only needed for "jpg"</param>
void SaveToStream(Stream stream, OutputFormat extension, int quality);
/// <param name="reduceColors">reduce the amount of colors to 256</param>
void SaveToStream(Stream stream, OutputFormat extension, int quality, bool reduceColors);
/// <summary>
/// Get the ToolStripMenuItem where plugins can place their Menu entrys

View file

@ -77,7 +77,8 @@ namespace Greenshot.Plugin {
/// <param name="stream">The Stream to save to</param>
/// <param name="format">The format to save with (png, jpg etc)</param>
/// <param name="quality">Jpeg quality</param>
void SaveToStream(Image image, Stream stream, OutputFormat format, int quality);
/// <param name="reduceColors">reduce the amount of colors to 256</param>
void SaveToStream(Image image, Stream stream, OutputFormat format, int quality, bool reduceColors);
/// <summary>
/// Saves the image to a temp file (random name) using the specified outputformat
@ -85,7 +86,8 @@ namespace Greenshot.Plugin {
/// <param name="image">The Image to save</param>
/// <param name="format">The format to save with (png, jpg etc)</param>
/// <param name="quality">Jpeg quality</param>
string SaveToTmpFile(Image image, OutputFormat outputFormat, int quality);
/// <param name="reduceColors">reduce the amount of colors to 256</param>
string SaveToTmpFile(Image image, OutputFormat outputFormat, int quality, bool reduceColors);
/// <summary>
/// Saves the image to a temp file, but the name is build with the capture details & pattern
@ -94,7 +96,8 @@ namespace Greenshot.Plugin {
/// <param name="captureDetails">captureDetails with the information to build the filename</param>
/// <param name="outputformat">The format to save with (png, jpg etc)</param>
/// <param name="quality">Jpeg quality</param>
string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputFormat outputFormat, int quality);
/// <param name="reduceColors">reduce the amount of colors to 256</param>
string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputFormat outputFormat, int quality, bool reduceColors);
/// <summary>
/// Return a filename for the current image format (png,jpg etc) with the default file pattern

View file

@ -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);