mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added auto use JPEG image format option instead of previous image format 2 option for UI to be more user friendly
This commit is contained in:
parent
c57c643d79
commit
bcbaa0e767
5 changed files with 3045 additions and 1286 deletions
76
ShareX/Forms/TaskSettingsForm.Designer.cs
generated
76
ShareX/Forms/TaskSettingsForm.Designer.cs
generated
|
@ -65,16 +65,14 @@ private void InitializeComponent()
|
|||
this.tcImage = new System.Windows.Forms.TabControl();
|
||||
this.tpQuality = new System.Windows.Forms.TabPage();
|
||||
this.pImage = new System.Windows.Forms.Panel();
|
||||
this.cbImageAutoUseJPEG = new System.Windows.Forms.CheckBox();
|
||||
this.lblImageFormat = new System.Windows.Forms.Label();
|
||||
this.cbImageFileExist = new System.Windows.Forms.ComboBox();
|
||||
this.lblUseImageFormat2After = new System.Windows.Forms.Label();
|
||||
this.lblImageFileExist = new System.Windows.Forms.Label();
|
||||
this.nudUseImageFormat2After = new System.Windows.Forms.NumericUpDown();
|
||||
this.lblImageFormat2 = new System.Windows.Forms.Label();
|
||||
this.lblUseImageFormat2AfterHint = new System.Windows.Forms.Label();
|
||||
this.nudImageAutoUseJPEGSize = new System.Windows.Forms.NumericUpDown();
|
||||
this.lblImageSizeLimitHint = new System.Windows.Forms.Label();
|
||||
this.nudImageJPEGQuality = new System.Windows.Forms.NumericUpDown();
|
||||
this.cbImageFormat = new System.Windows.Forms.ComboBox();
|
||||
this.cbImageFormat2 = new System.Windows.Forms.ComboBox();
|
||||
this.lblImageJPEGQualityHint = new System.Windows.Forms.Label();
|
||||
this.lblImageGIFQuality = new System.Windows.Forms.Label();
|
||||
this.lblImageJPEGQuality = new System.Windows.Forms.Label();
|
||||
|
@ -244,7 +242,7 @@ private void InitializeComponent()
|
|||
this.tcImage.SuspendLayout();
|
||||
this.tpQuality.SuspendLayout();
|
||||
this.pImage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudUseImageFormat2After)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudImageAutoUseJPEGSize)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudImageJPEGQuality)).BeginInit();
|
||||
this.tpEffects.SuspendLayout();
|
||||
this.tpThumbnail.SuspendLayout();
|
||||
|
@ -554,16 +552,14 @@ private void InitializeComponent()
|
|||
//
|
||||
// pImage
|
||||
//
|
||||
this.pImage.Controls.Add(this.cbImageAutoUseJPEG);
|
||||
this.pImage.Controls.Add(this.lblImageFormat);
|
||||
this.pImage.Controls.Add(this.cbImageFileExist);
|
||||
this.pImage.Controls.Add(this.lblUseImageFormat2After);
|
||||
this.pImage.Controls.Add(this.lblImageFileExist);
|
||||
this.pImage.Controls.Add(this.nudUseImageFormat2After);
|
||||
this.pImage.Controls.Add(this.lblImageFormat2);
|
||||
this.pImage.Controls.Add(this.lblUseImageFormat2AfterHint);
|
||||
this.pImage.Controls.Add(this.nudImageAutoUseJPEGSize);
|
||||
this.pImage.Controls.Add(this.lblImageSizeLimitHint);
|
||||
this.pImage.Controls.Add(this.nudImageJPEGQuality);
|
||||
this.pImage.Controls.Add(this.cbImageFormat);
|
||||
this.pImage.Controls.Add(this.cbImageFormat2);
|
||||
this.pImage.Controls.Add(this.lblImageJPEGQualityHint);
|
||||
this.pImage.Controls.Add(this.lblImageGIFQuality);
|
||||
this.pImage.Controls.Add(this.lblImageJPEGQuality);
|
||||
|
@ -571,6 +567,13 @@ private void InitializeComponent()
|
|||
resources.ApplyResources(this.pImage, "pImage");
|
||||
this.pImage.Name = "pImage";
|
||||
//
|
||||
// cbImageAutoUseJPEG
|
||||
//
|
||||
resources.ApplyResources(this.cbImageAutoUseJPEG, "cbImageAutoUseJPEG");
|
||||
this.cbImageAutoUseJPEG.Name = "cbImageAutoUseJPEG";
|
||||
this.cbImageAutoUseJPEG.UseVisualStyleBackColor = true;
|
||||
this.cbImageAutoUseJPEG.CheckedChanged += new System.EventHandler(this.cbImageAutoUseJPEG_CheckedChanged);
|
||||
//
|
||||
// lblImageFormat
|
||||
//
|
||||
resources.ApplyResources(this.lblImageFormat, "lblImageFormat");
|
||||
|
@ -584,41 +587,36 @@ private void InitializeComponent()
|
|||
this.cbImageFileExist.Name = "cbImageFileExist";
|
||||
this.cbImageFileExist.SelectedIndexChanged += new System.EventHandler(this.cbImageFileExist_SelectedIndexChanged);
|
||||
//
|
||||
// lblUseImageFormat2After
|
||||
//
|
||||
resources.ApplyResources(this.lblUseImageFormat2After, "lblUseImageFormat2After");
|
||||
this.lblUseImageFormat2After.Name = "lblUseImageFormat2After";
|
||||
//
|
||||
// lblImageFileExist
|
||||
//
|
||||
resources.ApplyResources(this.lblImageFileExist, "lblImageFileExist");
|
||||
this.lblImageFileExist.Name = "lblImageFileExist";
|
||||
//
|
||||
// nudUseImageFormat2After
|
||||
// nudImageAutoUseJPEGSize
|
||||
//
|
||||
resources.ApplyResources(this.nudUseImageFormat2After, "nudUseImageFormat2After");
|
||||
this.nudUseImageFormat2After.Maximum = new decimal(new int[] {
|
||||
resources.ApplyResources(this.nudImageAutoUseJPEGSize, "nudImageAutoUseJPEGSize");
|
||||
this.nudImageAutoUseJPEGSize.Maximum = new decimal(new int[] {
|
||||
10000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudUseImageFormat2After.Name = "nudUseImageFormat2After";
|
||||
this.nudUseImageFormat2After.Value = new decimal(new int[] {
|
||||
this.nudImageAutoUseJPEGSize.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudImageAutoUseJPEGSize.Name = "nudImageAutoUseJPEGSize";
|
||||
this.nudImageAutoUseJPEGSize.Value = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudUseImageFormat2After.ValueChanged += new System.EventHandler(this.nudUseImageFormat2After_ValueChanged);
|
||||
this.nudImageAutoUseJPEGSize.ValueChanged += new System.EventHandler(this.nudImageAutoUseJPEGSize_ValueChanged);
|
||||
//
|
||||
// lblImageFormat2
|
||||
// lblImageSizeLimitHint
|
||||
//
|
||||
resources.ApplyResources(this.lblImageFormat2, "lblImageFormat2");
|
||||
this.lblImageFormat2.Name = "lblImageFormat2";
|
||||
//
|
||||
// lblUseImageFormat2AfterHint
|
||||
//
|
||||
resources.ApplyResources(this.lblUseImageFormat2AfterHint, "lblUseImageFormat2AfterHint");
|
||||
this.lblUseImageFormat2AfterHint.Name = "lblUseImageFormat2AfterHint";
|
||||
resources.ApplyResources(this.lblImageSizeLimitHint, "lblImageSizeLimitHint");
|
||||
this.lblImageSizeLimitHint.Name = "lblImageSizeLimitHint";
|
||||
//
|
||||
// nudImageJPEGQuality
|
||||
//
|
||||
|
@ -639,14 +637,6 @@ private void InitializeComponent()
|
|||
this.cbImageFormat.Name = "cbImageFormat";
|
||||
this.cbImageFormat.SelectedIndexChanged += new System.EventHandler(this.cbImageFormat_SelectedIndexChanged);
|
||||
//
|
||||
// cbImageFormat2
|
||||
//
|
||||
this.cbImageFormat2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cbImageFormat2.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.cbImageFormat2, "cbImageFormat2");
|
||||
this.cbImageFormat2.Name = "cbImageFormat2";
|
||||
this.cbImageFormat2.SelectedIndexChanged += new System.EventHandler(this.cbImageFormat2_SelectedIndexChanged);
|
||||
//
|
||||
// lblImageJPEGQualityHint
|
||||
//
|
||||
resources.ApplyResources(this.lblImageJPEGQualityHint, "lblImageJPEGQualityHint");
|
||||
|
@ -2074,7 +2064,7 @@ private void InitializeComponent()
|
|||
this.tpQuality.PerformLayout();
|
||||
this.pImage.ResumeLayout(false);
|
||||
this.pImage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudUseImageFormat2After)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudImageAutoUseJPEGSize)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudImageJPEGQuality)).EndInit();
|
||||
this.tpEffects.ResumeLayout(false);
|
||||
this.tpEffects.PerformLayout();
|
||||
|
@ -2158,17 +2148,14 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.TabControl tcImage;
|
||||
private System.Windows.Forms.TabPage tpQuality;
|
||||
private System.Windows.Forms.Label lblImageFormat;
|
||||
private System.Windows.Forms.Label lblUseImageFormat2AfterHint;
|
||||
private System.Windows.Forms.Label lblImageSizeLimitHint;
|
||||
private System.Windows.Forms.ComboBox cbImageFormat;
|
||||
private System.Windows.Forms.Label lblImageJPEGQualityHint;
|
||||
private System.Windows.Forms.Label lblImageJPEGQuality;
|
||||
private System.Windows.Forms.ComboBox cbImageGIFQuality;
|
||||
private System.Windows.Forms.Label lblImageGIFQuality;
|
||||
private System.Windows.Forms.ComboBox cbImageFormat2;
|
||||
private System.Windows.Forms.NumericUpDown nudImageJPEGQuality;
|
||||
private System.Windows.Forms.Label lblImageFormat2;
|
||||
private System.Windows.Forms.NumericUpDown nudUseImageFormat2After;
|
||||
private System.Windows.Forms.Label lblUseImageFormat2After;
|
||||
private System.Windows.Forms.NumericUpDown nudImageAutoUseJPEGSize;
|
||||
private System.Windows.Forms.TabPage tpEffects;
|
||||
private System.Windows.Forms.TabControl tcCapture;
|
||||
private System.Windows.Forms.TabPage tpCaptureGeneral;
|
||||
|
@ -2345,5 +2332,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.CheckBox cbRegionCaptureIsFixedSize;
|
||||
private System.Windows.Forms.NumericUpDown nudRegionCaptureFixedSizeHeight;
|
||||
private System.Windows.Forms.CheckBox cbRegionCaptureShowFPS;
|
||||
private System.Windows.Forms.CheckBox cbImageAutoUseJPEG;
|
||||
}
|
||||
}
|
|
@ -183,9 +183,9 @@ public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
|
|||
nudImageJPEGQuality.SetValue(TaskSettings.ImageSettings.ImageJPEGQuality);
|
||||
cbImageGIFQuality.Items.AddRange(Helpers.GetLocalizedEnumDescriptions<GIFQuality>());
|
||||
cbImageGIFQuality.SelectedIndex = (int)TaskSettings.ImageSettings.ImageGIFQuality;
|
||||
nudUseImageFormat2After.SetValue(TaskSettings.ImageSettings.ImageSizeLimit);
|
||||
cbImageFormat2.Items.AddRange(Enum.GetNames(typeof(EImageFormat)));
|
||||
cbImageFormat2.SelectedIndex = (int)TaskSettings.ImageSettings.ImageFormat2;
|
||||
cbImageAutoUseJPEG.Checked = TaskSettings.ImageSettings.ImageAutoUseJPEG;
|
||||
nudImageAutoUseJPEGSize.Enabled = TaskSettings.ImageSettings.ImageAutoUseJPEG;
|
||||
nudImageAutoUseJPEGSize.SetValue(TaskSettings.ImageSettings.ImageAutoUseJPEGSize);
|
||||
cbImageFileExist.Items.Clear();
|
||||
cbImageFileExist.Items.AddRange(Helpers.GetLocalizedEnumDescriptions<FileExistAction>());
|
||||
cbImageFileExist.SelectedIndex = (int)TaskSettings.ImageSettings.FileExistAction;
|
||||
|
@ -713,25 +713,25 @@ private void cbImageFormat_SelectedIndexChanged(object sender, EventArgs e)
|
|||
TaskSettings.ImageSettings.ImageFormat = (EImageFormat)cbImageFormat.SelectedIndex;
|
||||
}
|
||||
|
||||
private void cbImageGIFQuality_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
TaskSettings.ImageSettings.ImageGIFQuality = (GIFQuality)cbImageGIFQuality.SelectedIndex;
|
||||
}
|
||||
|
||||
private void cbImageFormat2_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
TaskSettings.ImageSettings.ImageFormat2 = (EImageFormat)cbImageFormat2.SelectedIndex;
|
||||
}
|
||||
|
||||
private void nudImageJPEGQuality_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
TaskSettings.ImageSettings.ImageJPEGQuality = (int)nudImageJPEGQuality.Value;
|
||||
}
|
||||
|
||||
private void nudUseImageFormat2After_ValueChanged(object sender, EventArgs e)
|
||||
private void cbImageGIFQuality_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
TaskSettings.ImageSettings.ImageSizeLimit = (int)nudUseImageFormat2After.Value;
|
||||
cbImageFormat2.Enabled = TaskSettings.ImageSettings.ImageSizeLimit > 0;
|
||||
TaskSettings.ImageSettings.ImageGIFQuality = (GIFQuality)cbImageGIFQuality.SelectedIndex;
|
||||
}
|
||||
|
||||
private void cbImageAutoUseJPEG_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
TaskSettings.ImageSettings.ImageAutoUseJPEG = cbImageAutoUseJPEG.Checked;
|
||||
nudImageAutoUseJPEGSize.Enabled = TaskSettings.ImageSettings.ImageAutoUseJPEG;
|
||||
}
|
||||
|
||||
private void nudImageAutoUseJPEGSize_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
TaskSettings.ImageSettings.ImageAutoUseJPEGSize = (int)nudImageAutoUseJPEGSize.Value;
|
||||
}
|
||||
|
||||
private void cbImageFileExist_SelectedIndexChanged(object sender, EventArgs e)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -49,26 +49,14 @@ public static class TaskHelpers
|
|||
public static ImageData PrepareImage(Image img, TaskSettings taskSettings)
|
||||
{
|
||||
ImageData imageData = new ImageData();
|
||||
imageData.ImageStream = SaveImage(img, taskSettings.ImageSettings.ImageFormat, taskSettings);
|
||||
imageData.ImageFormat = taskSettings.ImageSettings.ImageFormat;
|
||||
|
||||
if (taskSettings.ImageSettings.ImageFormat == EImageFormat.JPEG)
|
||||
if (taskSettings.ImageSettings.ImageAutoUseJPEG && taskSettings.ImageSettings.ImageFormat != EImageFormat.JPEG &&
|
||||
imageData.ImageStream.Length > taskSettings.ImageSettings.ImageAutoUseJPEGSize * 1000)
|
||||
{
|
||||
img = ImageHelpers.FillBackground(img, Color.White);
|
||||
}
|
||||
|
||||
imageData.ImageStream = SaveImage(img, taskSettings.ImageSettings.ImageFormat, taskSettings);
|
||||
|
||||
int sizeLimit = taskSettings.ImageSettings.ImageSizeLimit * 1000;
|
||||
|
||||
if (taskSettings.ImageSettings.ImageFormat != taskSettings.ImageSettings.ImageFormat2 && sizeLimit > 0 && imageData.ImageStream.Length > sizeLimit)
|
||||
{
|
||||
if (taskSettings.ImageSettings.ImageFormat2 == EImageFormat.JPEG)
|
||||
{
|
||||
img = ImageHelpers.FillBackground(img, Color.White);
|
||||
}
|
||||
|
||||
imageData.ImageStream = SaveImage(img, taskSettings.ImageSettings.ImageFormat2, taskSettings);
|
||||
imageData.ImageFormat = taskSettings.ImageSettings.ImageFormat2;
|
||||
imageData.ImageStream = SaveImage(img, EImageFormat.JPEG, taskSettings);
|
||||
imageData.ImageFormat = EImageFormat.JPEG;
|
||||
}
|
||||
|
||||
return imageData;
|
||||
|
@ -130,6 +118,7 @@ public static MemoryStream SaveImage(Image img, EImageFormat imageFormat, int jp
|
|||
img.Save(stream, ImageFormat.Png);
|
||||
break;
|
||||
case EImageFormat.JPEG:
|
||||
img = ImageHelpers.FillBackground(img, Color.White);
|
||||
img.SaveJPG(stream, jpegQuality);
|
||||
break;
|
||||
case EImageFormat.GIF:
|
||||
|
|
|
@ -274,8 +274,8 @@ public class TaskSettingsImage
|
|||
public EImageFormat ImageFormat = EImageFormat.PNG;
|
||||
public int ImageJPEGQuality = 90;
|
||||
public GIFQuality ImageGIFQuality = GIFQuality.Default;
|
||||
public int ImageSizeLimit = 2048;
|
||||
public EImageFormat ImageFormat2 = EImageFormat.JPEG;
|
||||
public bool ImageAutoUseJPEG = true;
|
||||
public int ImageAutoUseJPEGSize = 2048;
|
||||
public FileExistAction FileExistAction = FileExistAction.Ask;
|
||||
|
||||
#endregion Image / General
|
||||
|
|
Loading…
Reference in a new issue