Add save of current image in bd sup edit context menu

This commit is contained in:
Nikolaj Olsson 2021-05-20 06:26:04 +02:00
parent 9017d6d0de
commit 734c0bd60d
2 changed files with 155 additions and 79 deletions

View File

@ -30,9 +30,10 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
Nikse.SubtitleEdit.Core.Common.TimeCode timeCode1 = new Nikse.SubtitleEdit.Core.Common.TimeCode(); Nikse.SubtitleEdit.Core.Common.TimeCode timeCode3 = new Nikse.SubtitleEdit.Core.Common.TimeCode();
Nikse.SubtitleEdit.Core.Common.TimeCode timeCode2 = new Nikse.SubtitleEdit.Core.Common.TimeCode(); Nikse.SubtitleEdit.Core.Common.TimeCode timeCode4 = new Nikse.SubtitleEdit.Core.Common.TimeCode();
this.groupBoxCurrent = new System.Windows.Forms.GroupBox(); this.groupBoxCurrent = new System.Windows.Forms.GroupBox();
this.labelSyntaxError = new System.Windows.Forms.Label();
this.buttonSetText = new System.Windows.Forms.Button(); this.buttonSetText = new System.Windows.Forms.Button();
this.labelCurrentSize = new System.Windows.Forms.Label(); this.labelCurrentSize = new System.Windows.Forms.Label();
this.buttonExportImage = new System.Windows.Forms.Button(); this.buttonExportImage = new System.Windows.Forms.Button();
@ -43,6 +44,8 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.numericUpDownY = new System.Windows.Forms.NumericUpDown(); this.numericUpDownY = new System.Windows.Forms.NumericUpDown();
this.numericUpDownX = new System.Windows.Forms.NumericUpDown(); this.numericUpDownX = new System.Windows.Forms.NumericUpDown();
this.checkBoxIsForced = new System.Windows.Forms.CheckBox(); this.checkBoxIsForced = new System.Windows.Forms.CheckBox();
this.timeUpDownEndTime = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.labelFrameRate = new System.Windows.Forms.Label(); this.labelFrameRate = new System.Windows.Forms.Label();
@ -109,6 +112,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.panelBackground = new System.Windows.Forms.Panel(); this.panelBackground = new System.Windows.Forms.Panel();
this.contextMenuStripBackground = new System.Windows.Forms.ContextMenuStrip(this.components); this.contextMenuStripBackground = new System.Windows.Forms.ContextMenuStrip(this.components);
this.setAspectRatio11ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.setAspectRatio11ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.videoPlayerContainer1 = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer();
this.pictureBoxMovableImage = new System.Windows.Forms.PictureBox(); this.pictureBoxMovableImage = new System.Windows.Forms.PictureBox();
this.contextMenuStripMovableImage = new System.Windows.Forms.ContextMenuStrip(this.components); this.contextMenuStripMovableImage = new System.Windows.Forms.ContextMenuStrip(this.components);
this.centerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.centerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -125,10 +129,8 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.columnHeaderDuration = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeaderDuration = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderText = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeaderText = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.timerSyntaxColor = new System.Windows.Forms.Timer(this.components); this.timerSyntaxColor = new System.Windows.Forms.Timer(this.components);
this.videoPlayerContainer1 = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator();
this.timeUpDownEndTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); this.saveImageAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.labelSyntaxError = new System.Windows.Forms.Label();
this.groupBoxCurrent.SuspendLayout(); this.groupBoxCurrent.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownY)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownY)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownX)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownX)).BeginInit();
@ -167,6 +169,16 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.groupBoxCurrent.TabStop = false; this.groupBoxCurrent.TabStop = false;
this.groupBoxCurrent.Text = "Current"; this.groupBoxCurrent.Text = "Current";
// //
// labelSyntaxError
//
this.labelSyntaxError.AutoSize = true;
this.labelSyntaxError.ForeColor = System.Drawing.Color.Red;
this.labelSyntaxError.Location = new System.Drawing.Point(103, 85);
this.labelSyntaxError.Name = "labelSyntaxError";
this.labelSyntaxError.Size = new System.Drawing.Size(83, 13);
this.labelSyntaxError.TabIndex = 12;
this.labelSyntaxError.Text = "labelSyntaxError";
//
// buttonSetText // buttonSetText
// //
this.buttonSetText.Location = new System.Drawing.Point(376, 75); this.buttonSetText.Location = new System.Drawing.Point(376, 75);
@ -280,6 +292,49 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.checkBoxIsForced.UseVisualStyleBackColor = true; this.checkBoxIsForced.UseVisualStyleBackColor = true;
this.checkBoxIsForced.CheckedChanged += new System.EventHandler(this.checkBoxIsForced_CheckedChanged); this.checkBoxIsForced.CheckedChanged += new System.EventHandler(this.checkBoxIsForced_CheckedChanged);
// //
// timeUpDownEndTime
//
this.timeUpDownEndTime.AutoSize = true;
this.timeUpDownEndTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownEndTime.BackColor = System.Drawing.SystemColors.Control;
this.timeUpDownEndTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F);
this.timeUpDownEndTime.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(155)))), ((int)(((byte)(155)))));
this.timeUpDownEndTime.Location = new System.Drawing.Point(74, 50);
this.timeUpDownEndTime.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownEndTime.Name = "timeUpDownEndTime";
this.timeUpDownEndTime.Size = new System.Drawing.Size(111, 27);
this.timeUpDownEndTime.TabIndex = 3;
timeCode3.Hours = 0;
timeCode3.Milliseconds = 0;
timeCode3.Minutes = 0;
timeCode3.Seconds = 0;
timeCode3.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode3.TotalMilliseconds = 0D;
timeCode3.TotalSeconds = 0D;
this.timeUpDownEndTime.TimeCode = timeCode3;
this.timeUpDownEndTime.UseVideoOffset = false;
//
// timeUpDownStartTime
//
this.timeUpDownStartTime.AutoSize = true;
this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownStartTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F);
this.timeUpDownStartTime.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(155)))), ((int)(((byte)(155)))));
this.timeUpDownStartTime.Location = new System.Drawing.Point(74, 18);
this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownStartTime.Name = "timeUpDownStartTime";
this.timeUpDownStartTime.Size = new System.Drawing.Size(111, 27);
this.timeUpDownStartTime.TabIndex = 1;
timeCode4.Hours = 0;
timeCode4.Milliseconds = 0;
timeCode4.Minutes = 0;
timeCode4.Seconds = 0;
timeCode4.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode4.TotalMilliseconds = 0D;
timeCode4.TotalSeconds = 0D;
this.timeUpDownStartTime.TimeCode = timeCode4;
this.timeUpDownStartTime.UseVideoOffset = false;
//
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
@ -820,6 +875,28 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.setAspectRatio11ToolStripMenuItem.Text = "Set aspect ratio 1:1"; this.setAspectRatio11ToolStripMenuItem.Text = "Set aspect ratio 1:1";
this.setAspectRatio11ToolStripMenuItem.Click += new System.EventHandler(this.setAspectRatio11ToolStripMenuItem_Click); this.setAspectRatio11ToolStripMenuItem.Click += new System.EventHandler(this.setAspectRatio11ToolStripMenuItem_Click);
// //
// videoPlayerContainer1
//
this.videoPlayerContainer1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
this.videoPlayerContainer1.Chapters = null;
this.videoPlayerContainer1.CurrentPosition = 0D;
this.videoPlayerContainer1.FontSizeFactor = 1F;
this.videoPlayerContainer1.LastParagraph = null;
this.videoPlayerContainer1.Location = new System.Drawing.Point(31, 107);
this.videoPlayerContainer1.Name = "videoPlayerContainer1";
this.videoPlayerContainer1.ShowFullscreenButton = true;
this.videoPlayerContainer1.ShowMuteButton = true;
this.videoPlayerContainer1.ShowStopButton = true;
this.videoPlayerContainer1.Size = new System.Drawing.Size(584, 333);
this.videoPlayerContainer1.SmpteMode = false;
this.videoPlayerContainer1.SubtitleText = "";
this.videoPlayerContainer1.TabIndex = 16;
this.videoPlayerContainer1.TextRightToLeft = System.Windows.Forms.RightToLeft.No;
this.videoPlayerContainer1.VideoHeight = 0;
this.videoPlayerContainer1.VideoPlayer = null;
this.videoPlayerContainer1.VideoWidth = 0;
this.videoPlayerContainer1.Volume = 0D;
//
// pictureBoxMovableImage // pictureBoxMovableImage
// //
this.pictureBoxMovableImage.ContextMenuStrip = this.contextMenuStripMovableImage; this.pictureBoxMovableImage.ContextMenuStrip = this.contextMenuStripMovableImage;
@ -836,9 +913,11 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.contextMenuStripMovableImage.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.contextMenuStripMovableImage.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.centerToolStripMenuItem, this.centerToolStripMenuItem,
this.toolStripSeparator4, this.toolStripSeparator4,
this.undoChangesForThisElementToolStripMenuItem}); this.undoChangesForThisElementToolStripMenuItem,
this.toolStripSeparator11,
this.saveImageAsToolStripMenuItem});
this.contextMenuStripMovableImage.Name = "contextMenuStripMovableImage"; this.contextMenuStripMovableImage.Name = "contextMenuStripMovableImage";
this.contextMenuStripMovableImage.Size = new System.Drawing.Size(237, 54); this.contextMenuStripMovableImage.Size = new System.Drawing.Size(237, 104);
// //
// centerToolStripMenuItem // centerToolStripMenuItem
// //
@ -934,80 +1013,17 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.timerSyntaxColor.Interval = 250; this.timerSyntaxColor.Interval = 250;
this.timerSyntaxColor.Tick += new System.EventHandler(this.timerSyntaxColor_Tick); this.timerSyntaxColor.Tick += new System.EventHandler(this.timerSyntaxColor_Tick);
// //
// videoPlayerContainer1 // toolStripSeparator11
// //
this.videoPlayerContainer1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18))))); this.toolStripSeparator11.Name = "toolStripSeparator11";
this.videoPlayerContainer1.Chapters = null; this.toolStripSeparator11.Size = new System.Drawing.Size(233, 6);
this.videoPlayerContainer1.CurrentPosition = 0D;
this.videoPlayerContainer1.FontSizeFactor = 1F;
this.videoPlayerContainer1.LastParagraph = null;
this.videoPlayerContainer1.Location = new System.Drawing.Point(31, 107);
this.videoPlayerContainer1.Name = "videoPlayerContainer1";
this.videoPlayerContainer1.ShowFullscreenButton = true;
this.videoPlayerContainer1.ShowMuteButton = true;
this.videoPlayerContainer1.ShowStopButton = true;
this.videoPlayerContainer1.Size = new System.Drawing.Size(584, 333);
this.videoPlayerContainer1.SmpteMode = false;
this.videoPlayerContainer1.SubtitleText = "";
this.videoPlayerContainer1.TabIndex = 16;
this.videoPlayerContainer1.TextRightToLeft = System.Windows.Forms.RightToLeft.No;
this.videoPlayerContainer1.VideoHeight = 0;
this.videoPlayerContainer1.VideoPlayer = null;
this.videoPlayerContainer1.VideoWidth = 0;
this.videoPlayerContainer1.Volume = 0D;
// //
// timeUpDownEndTime // saveImageAsToolStripMenuItem
// //
this.timeUpDownEndTime.AutoSize = true; this.saveImageAsToolStripMenuItem.Name = "saveImageAsToolStripMenuItem";
this.timeUpDownEndTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.saveImageAsToolStripMenuItem.Size = new System.Drawing.Size(236, 22);
this.timeUpDownEndTime.BackColor = System.Drawing.SystemColors.Control; this.saveImageAsToolStripMenuItem.Text = "Save image as...";
this.timeUpDownEndTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); this.saveImageAsToolStripMenuItem.Click += new System.EventHandler(this.saveImageAsToolStripMenuItem_Click);
this.timeUpDownEndTime.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(155)))), ((int)(((byte)(155)))));
this.timeUpDownEndTime.Location = new System.Drawing.Point(74, 50);
this.timeUpDownEndTime.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownEndTime.Name = "timeUpDownEndTime";
this.timeUpDownEndTime.Size = new System.Drawing.Size(111, 27);
this.timeUpDownEndTime.TabIndex = 3;
timeCode1.Hours = 0;
timeCode1.Milliseconds = 0;
timeCode1.Minutes = 0;
timeCode1.Seconds = 0;
timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode1.TotalMilliseconds = 0D;
timeCode1.TotalSeconds = 0D;
this.timeUpDownEndTime.TimeCode = timeCode1;
this.timeUpDownEndTime.UseVideoOffset = false;
//
// timeUpDownStartTime
//
this.timeUpDownStartTime.AutoSize = true;
this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownStartTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F);
this.timeUpDownStartTime.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(155)))), ((int)(((byte)(155)))));
this.timeUpDownStartTime.Location = new System.Drawing.Point(74, 18);
this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownStartTime.Name = "timeUpDownStartTime";
this.timeUpDownStartTime.Size = new System.Drawing.Size(111, 27);
this.timeUpDownStartTime.TabIndex = 1;
timeCode2.Hours = 0;
timeCode2.Milliseconds = 0;
timeCode2.Minutes = 0;
timeCode2.Seconds = 0;
timeCode2.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode2.TotalMilliseconds = 0D;
timeCode2.TotalSeconds = 0D;
this.timeUpDownStartTime.TimeCode = timeCode2;
this.timeUpDownStartTime.UseVideoOffset = false;
//
// labelSyntaxError
//
this.labelSyntaxError.AutoSize = true;
this.labelSyntaxError.ForeColor = System.Drawing.Color.Red;
this.labelSyntaxError.Location = new System.Drawing.Point(103, 85);
this.labelSyntaxError.Name = "labelSyntaxError";
this.labelSyntaxError.Size = new System.Drawing.Size(83, 13);
this.labelSyntaxError.TabIndex = 12;
this.labelSyntaxError.Text = "labelSyntaxError";
// //
// BinEdit // BinEdit
// //
@ -1152,5 +1168,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
private System.Windows.Forms.ColumnHeader columnHeaderText; private System.Windows.Forms.ColumnHeader columnHeaderText;
private System.Windows.Forms.Timer timerSyntaxColor; private System.Windows.Forms.Timer timerSyntaxColor;
private System.Windows.Forms.Label labelSyntaxError; private System.Windows.Forms.Label labelSyntaxError;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator11;
private System.Windows.Forms.ToolStripMenuItem saveImageAsToolStripMenuItem;
} }
} }

View File

@ -263,6 +263,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
adjustDisplayTimeForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.Main.Menu.ContextMenu.AdjustDisplayDurationForSelectedLines; adjustDisplayTimeForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.Main.Menu.ContextMenu.AdjustDisplayDurationForSelectedLines;
applyDurationLimitsForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.Main.Menu.ContextMenu.ApplyDurationLimitsForSelectedLines; applyDurationLimitsForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.Main.Menu.ContextMenu.ApplyDurationLimitsForSelectedLines;
setAspectRatio11ToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.SetAspectRatio11; setAspectRatio11ToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.SetAspectRatio11;
saveImageAsToolStripMenuItem.Text = LanguageSettings.Current.VobSubOcr.SaveSubtitleImageAs;
labelStart.Text = LanguageSettings.Current.General.StartTime; labelStart.Text = LanguageSettings.Current.General.StartTime;
labelEndTime.Text = LanguageSettings.Current.General.EndTime; labelEndTime.Text = LanguageSettings.Current.General.EndTime;
@ -3825,6 +3826,63 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
labelSyntaxError.Text = errorText; labelSyntaxError.Text = errorText;
} }
} }
private void saveImageAsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (subtitleListView1.SelectedItems.Count < 1)
{
return;
}
var index = subtitleListView1.SelectedIndices[0];
saveFileDialog1.Title = LanguageSettings.Current.VobSubOcr.SaveSubtitleImageAs;
saveFileDialog1.AddExtension = true;
saveFileDialog1.FileName = "Image" + (index + 1);
saveFileDialog1.Filter = "PNG image|*.png|BMP image|*.bmp|GIF image|*.gif|TIFF image|*.tiff";
saveFileDialog1.FilterIndex = 0;
var result = saveFileDialog1.ShowDialog(this);
if (result != DialogResult.OK)
{
return;
}
var extra = _extra[index];
var bd = _binSubtitles[index];
var bmp = extra.Bitmap ?? GetBitmap(bd);
if (bmp == null)
{
MessageBox.Show("No image!");
return;
}
try
{
if (saveFileDialog1.FilterIndex == 0)
{
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png);
}
else if (saveFileDialog1.FilterIndex == 1)
{
bmp.Save(saveFileDialog1.FileName);
}
else if (saveFileDialog1.FilterIndex == 2)
{
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Gif);
}
else
{
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Tiff);
}
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
finally
{
bmp.Dispose();
}
}
} }
} }