fixed #151: GIF size checking

This commit is contained in:
Jaex 2014-05-27 15:58:59 +03:00
parent 80eca25509
commit 36690d26dc
5 changed files with 32 additions and 21 deletions

View file

@ -28,6 +28,7 @@ You should have received a copy of the GNU General Public License
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
namespace ScreenCaptureLib
{
@ -86,6 +87,12 @@ public IEnumerable<Image> GetImageEnumerator()
{
foreach (LocationInfo index in indexList)
{
if (index.Location > int.MaxValue || index.Length > int.MaxValue)
{
MessageBox.Show("Cache file size can't exceed 2.14 GB.\r\nPlease use FFmpeg screen recording instead of GIF.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
yield break;
}
using (MemoryStream ms = new MemoryStream())
{
fsCache.CopyStreamTo(ms, (int)index.Location, (int)index.Length);

View file

@ -59,7 +59,7 @@ public static ScreenRecordForm Instance
private ScreenRecordForm()
{
TrayIcon.Text = "ShareX - Screen recording";
TrayIcon.Text = "ShareX";
TrayIcon.MouseClick += TrayIcon_MouseClick;
}
@ -125,6 +125,7 @@ public void StartRecording(TaskSettings TaskSettings)
IsRecording = true;
Screenshot.CaptureCursor = TaskSettings.CaptureSettings.ShowCursor;
TrayIcon.Text = "ShareX - Waiting...";
TrayIcon.Icon = Resources.control_record_yellow.ToIcon();
TrayIcon.Visible = true;
@ -174,9 +175,11 @@ public void StartRecording(TaskSettings TaskSettings)
this.InvokeSafe(() =>
{
screenRegionManager.ChangeColor(Color.FromArgb(0, 255, 0));
TrayIcon.Icon = Resources.control_record.ToIcon();
});
TrayIcon.Text = "ShareX - Click tray icon to stop recording.";
TrayIcon.Icon = Resources.control_record.ToIcon();
screenRecorder.StartRecording();
}
finally
@ -191,6 +194,7 @@ public void StartRecording(TaskSettings TaskSettings)
{
if (screenRecorder != null)
{
TrayIcon.Text = "ShareX - Encoding...";
TrayIcon.Icon = Resources.camcorder_pencil.ToIcon();
string sourceFilePath = path;

View file

@ -110,6 +110,7 @@ private void InitializeComponent()
this.tpCaptureShape = new System.Windows.Forms.TabPage();
this.pgShapesCapture = new System.Windows.Forms.PropertyGrid();
this.tpScreenRecorder = new System.Windows.Forms.TabPage();
this.lblScreenRecorderFixedDuration = new System.Windows.Forms.Label();
this.nudScreenRecordFPS = new System.Windows.Forms.NumericUpDown();
this.lblScreenRecordFPS = new System.Windows.Forms.Label();
this.chkRunScreencastCLI = new System.Windows.Forms.CheckBox();
@ -165,7 +166,6 @@ private void InitializeComponent()
this.tpAdvanced = new System.Windows.Forms.TabPage();
this.pgTaskSettings = new System.Windows.Forms.PropertyGrid();
this.chkUseDefaultAdvancedSettings = new System.Windows.Forms.CheckBox();
this.lblScreenRecorderFixedDuration = new System.Windows.Forms.Label();
this.tcHotkeySettings.SuspendLayout();
this.tpTask.SuspendLayout();
this.cmsDestinations.SuspendLayout();
@ -1147,6 +1147,15 @@ private void InitializeComponent()
this.tpScreenRecorder.Text = "Screen recorder";
this.tpScreenRecorder.UseVisualStyleBackColor = true;
//
// lblScreenRecorderFixedDuration
//
this.lblScreenRecorderFixedDuration.AutoSize = true;
this.lblScreenRecorderFixedDuration.Location = new System.Drawing.Point(211, 115);
this.lblScreenRecorderFixedDuration.Name = "lblScreenRecorderFixedDuration";
this.lblScreenRecorderFixedDuration.Size = new System.Drawing.Size(47, 13);
this.lblScreenRecorderFixedDuration.TabIndex = 15;
this.lblScreenRecorderFixedDuration.Text = "seconds";
//
// nudScreenRecordFPS
//
this.nudScreenRecordFPS.Location = new System.Drawing.Point(144, 64);
@ -1319,7 +1328,7 @@ private void InitializeComponent()
//
this.nudGIFFPS.Location = new System.Drawing.Point(144, 88);
this.nudGIFFPS.Maximum = new decimal(new int[] {
30,
15,
0,
0,
0});
@ -1789,15 +1798,6 @@ private void InitializeComponent()
this.chkUseDefaultAdvancedSettings.UseVisualStyleBackColor = true;
this.chkUseDefaultAdvancedSettings.CheckedChanged += new System.EventHandler(this.chkUseDefaultAdvancedSettings_CheckedChanged);
//
// lblScreenRecorderFixedDuration
//
this.lblScreenRecorderFixedDuration.AutoSize = true;
this.lblScreenRecorderFixedDuration.Location = new System.Drawing.Point(210, 115);
this.lblScreenRecorderFixedDuration.Name = "lblScreenRecorderFixedDuration";
this.lblScreenRecorderFixedDuration.Size = new System.Drawing.Size(47, 13);
this.lblScreenRecorderFixedDuration.TabIndex = 15;
this.lblScreenRecorderFixedDuration.Text = "seconds";
//
// TaskSettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View file

@ -164,8 +164,8 @@ public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
chkRunScreencastCLI.Checked = TaskSettings.CaptureSettings.RunScreencastCLI;
UpdateVideoEncoders();
nudGIFFPS.Value = TaskSettings.CaptureSettings.GIFFPS;
nudScreenRecordFPS.Value = TaskSettings.CaptureSettings.ScreenRecordFPS;
nudScreenRecordFPS.Value = TaskSettings.CaptureSettings.ScreenRecordFPS.Between((int)nudScreenRecordFPS.Minimum, (int)nudScreenRecordFPS.Maximum);
nudGIFFPS.Value = TaskSettings.CaptureSettings.GIFFPS.Between((int)nudGIFFPS.Minimum, (int)nudGIFFPS.Maximum);
cbScreenRecorderFixedDuration.Checked = TaskSettings.CaptureSettings.ScreenRecordFixedDuration;
nudScreenRecorderDuration.Enabled = TaskSettings.CaptureSettings.ScreenRecordFixedDuration;
nudScreenRecorderDuration.Value = (decimal)TaskSettings.CaptureSettings.ScreenRecordDuration;

View file

@ -112,21 +112,21 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="cmsAfterCapture.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="cmsAfterCapture.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="cmsAfterUpload.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="cmsAfterUpload.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>160, 17</value>
</metadata>
<metadata name="cmsTask.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="cmsTask.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>299, 17</value>
</metadata>
<metadata name="cmsDestinations.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="cmsDestinations.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>396, 17</value>
</metadata>
</root>