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:
Jaex 2016-07-22 10:22:18 +03:00
parent c57c643d79
commit bcbaa0e767
5 changed files with 3045 additions and 1286 deletions

View file

@ -65,16 +65,14 @@ private void InitializeComponent()
this.tcImage = new System.Windows.Forms.TabControl(); this.tcImage = new System.Windows.Forms.TabControl();
this.tpQuality = new System.Windows.Forms.TabPage(); this.tpQuality = new System.Windows.Forms.TabPage();
this.pImage = new System.Windows.Forms.Panel(); this.pImage = new System.Windows.Forms.Panel();
this.cbImageAutoUseJPEG = new System.Windows.Forms.CheckBox();
this.lblImageFormat = new System.Windows.Forms.Label(); this.lblImageFormat = new System.Windows.Forms.Label();
this.cbImageFileExist = new System.Windows.Forms.ComboBox(); this.cbImageFileExist = new System.Windows.Forms.ComboBox();
this.lblUseImageFormat2After = new System.Windows.Forms.Label();
this.lblImageFileExist = new System.Windows.Forms.Label(); this.lblImageFileExist = new System.Windows.Forms.Label();
this.nudUseImageFormat2After = new System.Windows.Forms.NumericUpDown(); this.nudImageAutoUseJPEGSize = new System.Windows.Forms.NumericUpDown();
this.lblImageFormat2 = new System.Windows.Forms.Label(); this.lblImageSizeLimitHint = new System.Windows.Forms.Label();
this.lblUseImageFormat2AfterHint = new System.Windows.Forms.Label();
this.nudImageJPEGQuality = new System.Windows.Forms.NumericUpDown(); this.nudImageJPEGQuality = new System.Windows.Forms.NumericUpDown();
this.cbImageFormat = new System.Windows.Forms.ComboBox(); this.cbImageFormat = new System.Windows.Forms.ComboBox();
this.cbImageFormat2 = new System.Windows.Forms.ComboBox();
this.lblImageJPEGQualityHint = new System.Windows.Forms.Label(); this.lblImageJPEGQualityHint = new System.Windows.Forms.Label();
this.lblImageGIFQuality = new System.Windows.Forms.Label(); this.lblImageGIFQuality = new System.Windows.Forms.Label();
this.lblImageJPEGQuality = new System.Windows.Forms.Label(); this.lblImageJPEGQuality = new System.Windows.Forms.Label();
@ -244,7 +242,7 @@ private void InitializeComponent()
this.tcImage.SuspendLayout(); this.tcImage.SuspendLayout();
this.tpQuality.SuspendLayout(); this.tpQuality.SuspendLayout();
this.pImage.SuspendLayout(); this.pImage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudUseImageFormat2After)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudImageAutoUseJPEGSize)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudImageJPEGQuality)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudImageJPEGQuality)).BeginInit();
this.tpEffects.SuspendLayout(); this.tpEffects.SuspendLayout();
this.tpThumbnail.SuspendLayout(); this.tpThumbnail.SuspendLayout();
@ -554,16 +552,14 @@ private void InitializeComponent()
// //
// pImage // pImage
// //
this.pImage.Controls.Add(this.cbImageAutoUseJPEG);
this.pImage.Controls.Add(this.lblImageFormat); this.pImage.Controls.Add(this.lblImageFormat);
this.pImage.Controls.Add(this.cbImageFileExist); this.pImage.Controls.Add(this.cbImageFileExist);
this.pImage.Controls.Add(this.lblUseImageFormat2After);
this.pImage.Controls.Add(this.lblImageFileExist); this.pImage.Controls.Add(this.lblImageFileExist);
this.pImage.Controls.Add(this.nudUseImageFormat2After); this.pImage.Controls.Add(this.nudImageAutoUseJPEGSize);
this.pImage.Controls.Add(this.lblImageFormat2); this.pImage.Controls.Add(this.lblImageSizeLimitHint);
this.pImage.Controls.Add(this.lblUseImageFormat2AfterHint);
this.pImage.Controls.Add(this.nudImageJPEGQuality); this.pImage.Controls.Add(this.nudImageJPEGQuality);
this.pImage.Controls.Add(this.cbImageFormat); this.pImage.Controls.Add(this.cbImageFormat);
this.pImage.Controls.Add(this.cbImageFormat2);
this.pImage.Controls.Add(this.lblImageJPEGQualityHint); this.pImage.Controls.Add(this.lblImageJPEGQualityHint);
this.pImage.Controls.Add(this.lblImageGIFQuality); this.pImage.Controls.Add(this.lblImageGIFQuality);
this.pImage.Controls.Add(this.lblImageJPEGQuality); this.pImage.Controls.Add(this.lblImageJPEGQuality);
@ -571,6 +567,13 @@ private void InitializeComponent()
resources.ApplyResources(this.pImage, "pImage"); resources.ApplyResources(this.pImage, "pImage");
this.pImage.Name = "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 // lblImageFormat
// //
resources.ApplyResources(this.lblImageFormat, "lblImageFormat"); resources.ApplyResources(this.lblImageFormat, "lblImageFormat");
@ -584,41 +587,36 @@ private void InitializeComponent()
this.cbImageFileExist.Name = "cbImageFileExist"; this.cbImageFileExist.Name = "cbImageFileExist";
this.cbImageFileExist.SelectedIndexChanged += new System.EventHandler(this.cbImageFileExist_SelectedIndexChanged); this.cbImageFileExist.SelectedIndexChanged += new System.EventHandler(this.cbImageFileExist_SelectedIndexChanged);
// //
// lblUseImageFormat2After
//
resources.ApplyResources(this.lblUseImageFormat2After, "lblUseImageFormat2After");
this.lblUseImageFormat2After.Name = "lblUseImageFormat2After";
//
// lblImageFileExist // lblImageFileExist
// //
resources.ApplyResources(this.lblImageFileExist, "lblImageFileExist"); resources.ApplyResources(this.lblImageFileExist, "lblImageFileExist");
this.lblImageFileExist.Name = "lblImageFileExist"; this.lblImageFileExist.Name = "lblImageFileExist";
// //
// nudUseImageFormat2After // nudImageAutoUseJPEGSize
// //
resources.ApplyResources(this.nudUseImageFormat2After, "nudUseImageFormat2After"); resources.ApplyResources(this.nudImageAutoUseJPEGSize, "nudImageAutoUseJPEGSize");
this.nudUseImageFormat2After.Maximum = new decimal(new int[] { this.nudImageAutoUseJPEGSize.Maximum = new decimal(new int[] {
10000, 10000,
0, 0,
0, 0,
0}); 0});
this.nudUseImageFormat2After.Name = "nudUseImageFormat2After"; this.nudImageAutoUseJPEGSize.Minimum = new decimal(new int[] {
this.nudUseImageFormat2After.Value = new decimal(new int[] { 100,
0,
0,
0});
this.nudImageAutoUseJPEGSize.Name = "nudImageAutoUseJPEGSize";
this.nudImageAutoUseJPEGSize.Value = new decimal(new int[] {
2048, 2048,
0, 0,
0, 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"); resources.ApplyResources(this.lblImageSizeLimitHint, "lblImageSizeLimitHint");
this.lblImageFormat2.Name = "lblImageFormat2"; this.lblImageSizeLimitHint.Name = "lblImageSizeLimitHint";
//
// lblUseImageFormat2AfterHint
//
resources.ApplyResources(this.lblUseImageFormat2AfterHint, "lblUseImageFormat2AfterHint");
this.lblUseImageFormat2AfterHint.Name = "lblUseImageFormat2AfterHint";
// //
// nudImageJPEGQuality // nudImageJPEGQuality
// //
@ -639,14 +637,6 @@ private void InitializeComponent()
this.cbImageFormat.Name = "cbImageFormat"; this.cbImageFormat.Name = "cbImageFormat";
this.cbImageFormat.SelectedIndexChanged += new System.EventHandler(this.cbImageFormat_SelectedIndexChanged); 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 // lblImageJPEGQualityHint
// //
resources.ApplyResources(this.lblImageJPEGQualityHint, "lblImageJPEGQualityHint"); resources.ApplyResources(this.lblImageJPEGQualityHint, "lblImageJPEGQualityHint");
@ -2074,7 +2064,7 @@ private void InitializeComponent()
this.tpQuality.PerformLayout(); this.tpQuality.PerformLayout();
this.pImage.ResumeLayout(false); this.pImage.ResumeLayout(false);
this.pImage.PerformLayout(); this.pImage.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudUseImageFormat2After)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudImageAutoUseJPEGSize)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudImageJPEGQuality)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudImageJPEGQuality)).EndInit();
this.tpEffects.ResumeLayout(false); this.tpEffects.ResumeLayout(false);
this.tpEffects.PerformLayout(); this.tpEffects.PerformLayout();
@ -2158,17 +2148,14 @@ private void InitializeComponent()
private System.Windows.Forms.TabControl tcImage; private System.Windows.Forms.TabControl tcImage;
private System.Windows.Forms.TabPage tpQuality; private System.Windows.Forms.TabPage tpQuality;
private System.Windows.Forms.Label lblImageFormat; 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.ComboBox cbImageFormat;
private System.Windows.Forms.Label lblImageJPEGQualityHint; private System.Windows.Forms.Label lblImageJPEGQualityHint;
private System.Windows.Forms.Label lblImageJPEGQuality; private System.Windows.Forms.Label lblImageJPEGQuality;
private System.Windows.Forms.ComboBox cbImageGIFQuality; private System.Windows.Forms.ComboBox cbImageGIFQuality;
private System.Windows.Forms.Label lblImageGIFQuality; private System.Windows.Forms.Label lblImageGIFQuality;
private System.Windows.Forms.ComboBox cbImageFormat2;
private System.Windows.Forms.NumericUpDown nudImageJPEGQuality; private System.Windows.Forms.NumericUpDown nudImageJPEGQuality;
private System.Windows.Forms.Label lblImageFormat2; private System.Windows.Forms.NumericUpDown nudImageAutoUseJPEGSize;
private System.Windows.Forms.NumericUpDown nudUseImageFormat2After;
private System.Windows.Forms.Label lblUseImageFormat2After;
private System.Windows.Forms.TabPage tpEffects; private System.Windows.Forms.TabPage tpEffects;
private System.Windows.Forms.TabControl tcCapture; private System.Windows.Forms.TabControl tcCapture;
private System.Windows.Forms.TabPage tpCaptureGeneral; private System.Windows.Forms.TabPage tpCaptureGeneral;
@ -2345,5 +2332,6 @@ private void InitializeComponent()
private System.Windows.Forms.CheckBox cbRegionCaptureIsFixedSize; private System.Windows.Forms.CheckBox cbRegionCaptureIsFixedSize;
private System.Windows.Forms.NumericUpDown nudRegionCaptureFixedSizeHeight; private System.Windows.Forms.NumericUpDown nudRegionCaptureFixedSizeHeight;
private System.Windows.Forms.CheckBox cbRegionCaptureShowFPS; private System.Windows.Forms.CheckBox cbRegionCaptureShowFPS;
private System.Windows.Forms.CheckBox cbImageAutoUseJPEG;
} }
} }

View file

@ -183,9 +183,9 @@ public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
nudImageJPEGQuality.SetValue(TaskSettings.ImageSettings.ImageJPEGQuality); nudImageJPEGQuality.SetValue(TaskSettings.ImageSettings.ImageJPEGQuality);
cbImageGIFQuality.Items.AddRange(Helpers.GetLocalizedEnumDescriptions<GIFQuality>()); cbImageGIFQuality.Items.AddRange(Helpers.GetLocalizedEnumDescriptions<GIFQuality>());
cbImageGIFQuality.SelectedIndex = (int)TaskSettings.ImageSettings.ImageGIFQuality; cbImageGIFQuality.SelectedIndex = (int)TaskSettings.ImageSettings.ImageGIFQuality;
nudUseImageFormat2After.SetValue(TaskSettings.ImageSettings.ImageSizeLimit); cbImageAutoUseJPEG.Checked = TaskSettings.ImageSettings.ImageAutoUseJPEG;
cbImageFormat2.Items.AddRange(Enum.GetNames(typeof(EImageFormat))); nudImageAutoUseJPEGSize.Enabled = TaskSettings.ImageSettings.ImageAutoUseJPEG;
cbImageFormat2.SelectedIndex = (int)TaskSettings.ImageSettings.ImageFormat2; nudImageAutoUseJPEGSize.SetValue(TaskSettings.ImageSettings.ImageAutoUseJPEGSize);
cbImageFileExist.Items.Clear(); cbImageFileExist.Items.Clear();
cbImageFileExist.Items.AddRange(Helpers.GetLocalizedEnumDescriptions<FileExistAction>()); cbImageFileExist.Items.AddRange(Helpers.GetLocalizedEnumDescriptions<FileExistAction>());
cbImageFileExist.SelectedIndex = (int)TaskSettings.ImageSettings.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; 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) private void nudImageJPEGQuality_ValueChanged(object sender, EventArgs e)
{ {
TaskSettings.ImageSettings.ImageJPEGQuality = (int)nudImageJPEGQuality.Value; 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; TaskSettings.ImageSettings.ImageGIFQuality = (GIFQuality)cbImageGIFQuality.SelectedIndex;
cbImageFormat2.Enabled = TaskSettings.ImageSettings.ImageSizeLimit > 0; }
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) private void cbImageFileExist_SelectedIndexChanged(object sender, EventArgs e)

File diff suppressed because it is too large Load diff

View file

@ -49,26 +49,14 @@ public static class TaskHelpers
public static ImageData PrepareImage(Image img, TaskSettings taskSettings) public static ImageData PrepareImage(Image img, TaskSettings taskSettings)
{ {
ImageData imageData = new ImageData(); ImageData imageData = new ImageData();
imageData.ImageStream = SaveImage(img, taskSettings.ImageSettings.ImageFormat, taskSettings);
imageData.ImageFormat = taskSettings.ImageSettings.ImageFormat; 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, EImageFormat.JPEG, taskSettings);
} imageData.ImageFormat = EImageFormat.JPEG;
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;
} }
return imageData; return imageData;
@ -130,6 +118,7 @@ public static MemoryStream SaveImage(Image img, EImageFormat imageFormat, int jp
img.Save(stream, ImageFormat.Png); img.Save(stream, ImageFormat.Png);
break; break;
case EImageFormat.JPEG: case EImageFormat.JPEG:
img = ImageHelpers.FillBackground(img, Color.White);
img.SaveJPG(stream, jpegQuality); img.SaveJPG(stream, jpegQuality);
break; break;
case EImageFormat.GIF: case EImageFormat.GIF:

View file

@ -274,8 +274,8 @@ public class TaskSettingsImage
public EImageFormat ImageFormat = EImageFormat.PNG; public EImageFormat ImageFormat = EImageFormat.PNG;
public int ImageJPEGQuality = 90; public int ImageJPEGQuality = 90;
public GIFQuality ImageGIFQuality = GIFQuality.Default; public GIFQuality ImageGIFQuality = GIFQuality.Default;
public int ImageSizeLimit = 2048; public bool ImageAutoUseJPEG = true;
public EImageFormat ImageFormat2 = EImageFormat.JPEG; public int ImageAutoUseJPEGSize = 2048;
public FileExistAction FileExistAction = FileExistAction.Ask; public FileExistAction FileExistAction = FileExistAction.Ask;
#endregion Image / General #endregion Image / General