Add "change brightness" to bdedit

This commit is contained in:
Nikolaj Olsson 2021-01-12 21:30:30 +01:00
parent 0cdddc14df
commit 5153108bb8
14 changed files with 543 additions and 71 deletions

View File

@ -247,14 +247,20 @@ Note: Do check free disk space.</WaveFileMalformed>
<SetText>Set text...</SetText>
<QuickOcr>Quick OCR texts (for overview only)</QuickOcr>
<ResizeBitmaps>Resize images...</ResizeBitmaps>
<ChangeBrightness>Change brightness...</ChangeBrightness>
<ResizeBitmapsForSelectedLines>Resize images for selected lines...</ResizeBitmapsForSelectedLines>
<ChangeColorForSelectedLines>Change color for selected lines...</ChangeColorForSelectedLines>
<ChangeBrightnessForSelectedLines>Change brightness for selected lines...</ChangeBrightnessForSelectedLines>
<AlignSelectedLines>Align selected lines</AlignSelectedLines>
<CenterSelectedLines>Center selected lines (horizontally, keep vertical position)</CenterSelectedLines>
<TopAlignSelectedLines>Top align selected lines (keep horizontal position)</TopAlignSelectedLines>
<BottomAlignSelectedLines>Bottom align selected lines (keep horizontal position)</BottomAlignSelectedLines>
<SizeXY>Size: {0}x{1}</SizeXY>
<SetAspectRatio11>Set aspect ratio 1:1</SetAspectRatio11>
<ChangeBrightnessTitle>Change brightness</ChangeBrightnessTitle>
<BrightnessX>Brightness: {0}%</BrightnessX>
<ResizeTitle>Resize images</ResizeTitle>
<ResizeX>Resize: {0}%</ResizeX>
</BinEdit>
<Bookmarks>
<EditBookmark>Edit bookmark</EditBookmark>

View File

@ -1493,7 +1493,6 @@ namespace Nikse.SubtitleEdit.Core.Common
return true;
}
for (int i = 0; i < _bitmapData.Length; i++)
{
if (_bitmapData[i] != bitmap._bitmapData[i])
@ -1520,5 +1519,33 @@ namespace Nikse.SubtitleEdit.Core.Common
}
}
}
public void ChangeBrightness(decimal factor)
{
if (factor > 1)
{
for (int i = 0; i < _bitmapData.Length; i += 4)
{
int r = _bitmapData[i + 2];
int g = _bitmapData[i + 1];
int b = _bitmapData[i];
_bitmapData[i + 2] = (byte)Math.Min(byte.MaxValue, (int)(r * factor));
_bitmapData[i + 1] = (byte)Math.Min(byte.MaxValue, (int)(g * factor));
_bitmapData[i] = (byte)Math.Min(byte.MaxValue, (int)(b * factor));
}
}
else
{
for (int i = 0; i < _bitmapData.Length; i += 4)
{
int r = _bitmapData[i + 2];
int g = _bitmapData[i + 1];
int b = _bitmapData[i];
_bitmapData[i + 2] = (byte)Math.Max(0, (int)(r * factor));
_bitmapData[i + 1] = (byte)Math.Max(0, (int)(g * factor));
_bitmapData[i] = (byte)Math.Max(0, (int)(b * factor));
}
}
}
}
}

View File

@ -43,6 +43,8 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.numericUpDownY = new System.Windows.Forms.NumericUpDown();
this.numericUpDownX = new System.Windows.Forms.NumericUpDown();
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.groupBox2 = new System.Windows.Forms.GroupBox();
this.labelFrameRate = new System.Windows.Forms.Label();
@ -83,6 +85,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.appendSubtitleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
this.resizeBitmapsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.changeBrightnessToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.alignmentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
this.quickOCRTextsforOverviewOnlyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -99,6 +102,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.panelBackground = new System.Windows.Forms.Panel();
this.contextMenuStripBackground = new System.Windows.Forms.ContextMenuStrip(this.components);
this.setAspectRatio11ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.videoPlayerContainer1 = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer();
this.pictureBoxMovableImage = new System.Windows.Forms.PictureBox();
this.contextMenuStripMovableImage = new System.Windows.Forms.ContextMenuStrip(this.components);
this.centerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -108,10 +112,8 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.timerSubtitleOnVideo = new System.Windows.Forms.Timer(this.components);
this.labelVideoInfo = new System.Windows.Forms.Label();
this.videoPlayerContainer1 = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer();
this.timeUpDownEndTime = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.changeBrightnessForSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBoxCurrent.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownY)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownX)).BeginInit();
@ -262,6 +264,46 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.checkBoxIsForced.UseVisualStyleBackColor = true;
this.checkBoxIsForced.CheckedChanged += new System.EventHandler(this.checkBoxIsForced_CheckedChanged);
//
// timeUpDownEndTime
//
this.timeUpDownEndTime.AutoSize = true;
this.timeUpDownEndTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownEndTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F);
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.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;
//
// label1
//
this.label1.AutoSize = true;
@ -374,6 +416,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.toolStripSeparator7,
this.resizeImagesForSelectedLinesToolStripMenuItem,
this.colorSelectedLinesToolStripMenuItem,
this.changeBrightnessForSelectedLinesToolStripMenuItem,
this.toolStripSeparator6,
this.adjustAllTimesForSelectedLinesToolStripMenuItem,
this.adjustDisplayTimeForSelectedLinesToolStripMenuItem,
@ -381,7 +424,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.toolStripSeparatorInsertSub,
this.insertSubtitleAfterThisLineToolStripMenuItem});
this.contextMenuStripListView.Name = "contextMenuStripListView";
this.contextMenuStripListView.Size = new System.Drawing.Size(377, 314);
this.contextMenuStripListView.Size = new System.Drawing.Size(377, 358);
this.contextMenuStripListView.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripListView_Opening);
//
// deleteToolStripMenuItem
@ -567,8 +610,9 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.applyDurationLimitsToolStripMenuItem,
this.appendSubtitleToolStripMenuItem,
this.toolStripSeparator8,
this.resizeBitmapsToolStripMenuItem,
this.alignmentToolStripMenuItem,
this.resizeBitmapsToolStripMenuItem,
this.changeBrightnessToolStripMenuItem,
this.toolStripSeparator5,
this.quickOCRTextsforOverviewOnlyToolStripMenuItem});
this.toolStripMenuItemTools.Name = "toolStripMenuItemTools";
@ -608,6 +652,13 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.resizeBitmapsToolStripMenuItem.Text = "Resize bitmaps...";
this.resizeBitmapsToolStripMenuItem.Click += new System.EventHandler(this.resizeBitmapsToolStripMenuItem_Click);
//
// changeBrightnessToolStripMenuItem
//
this.changeBrightnessToolStripMenuItem.Name = "changeBrightnessToolStripMenuItem";
this.changeBrightnessToolStripMenuItem.Size = new System.Drawing.Size(262, 22);
this.changeBrightnessToolStripMenuItem.Text = "Change brightness...";
this.changeBrightnessToolStripMenuItem.Click += new System.EventHandler(this.changeBrightnessToolStripMenuItem_Click);
//
// alignmentToolStripMenuItem
//
this.alignmentToolStripMenuItem.Name = "alignmentToolStripMenuItem";
@ -726,6 +777,28 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.setAspectRatio11ToolStripMenuItem.Text = "Set aspect ratio 1:1";
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
//
this.pictureBoxMovableImage.ContextMenuStrip = this.contextMenuStripMovableImage;
@ -792,68 +865,6 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.labelVideoInfo.TabIndex = 9;
this.labelVideoInfo.Text = "Video info";
//
// 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;
//
// timeUpDownEndTime
//
this.timeUpDownEndTime.AutoSize = true;
this.timeUpDownEndTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownEndTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F);
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.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;
//
// subtitleListView1
//
this.subtitleListView1.AllowColumnReorder = true;
@ -881,6 +892,13 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.subtitleListView1.Click += new System.EventHandler(this.subtitleListView1_Click);
this.subtitleListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.subtitleListView1_KeyDown);
//
// changeBrightnessForSelectedLinesToolStripMenuItem
//
this.changeBrightnessForSelectedLinesToolStripMenuItem.Name = "changeBrightnessForSelectedLinesToolStripMenuItem";
this.changeBrightnessForSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(376, 22);
this.changeBrightnessForSelectedLinesToolStripMenuItem.Text = "Change brightness for selected lines...";
this.changeBrightnessForSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.changeBrightnessForSelectedLinesToolStripMenuItem_Click);
//
// BinEdit
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -1008,5 +1026,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
private System.Windows.Forms.ToolStripMenuItem alignmentToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip contextMenuStripBackground;
private System.Windows.Forms.ToolStripMenuItem setAspectRatio11ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem changeBrightnessToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem changeBrightnessForSelectedLinesToolStripMenuItem;
}
}

View File

@ -86,6 +86,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
applyDurationLimitsToolStripMenuItem.Text = LanguageSettings.Current.Main.Menu.Tools.ApplyDurationLimits;
appendSubtitleToolStripMenuItem.Text = LanguageSettings.Current.Main.Menu.Tools.AppendSubtitle;
resizeBitmapsToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.ResizeBitmaps;
changeBrightnessToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.ChangeBrightness;
alignmentToolStripMenuItem.Text = LanguageSettings.Current.Main.Menu.ContextMenu.Alignment;
quickOCRTextsforOverviewOnlyToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.QuickOcr;
videoToolStripMenuItem.Text = LanguageSettings.Current.Main.Menu.Video.Title;
@ -105,6 +106,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
bottomAlignSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.BottomAlignSelectedLines;
resizeImagesForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.ResizeBitmapsForSelectedLines;
colorSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.ChangeColorForSelectedLines;
changeBrightnessForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.ChangeBrightnessForSelectedLines;
adjustAllTimesForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.Main.Menu.ContextMenu.ShowSelectedLinesEarlierLater;
adjustDisplayTimeForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.Main.Menu.ContextMenu.AdjustDisplayDurationForSelectedLines;
applyDurationLimitsForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.Main.Menu.ContextMenu.AdjustDisplayDurationForSelectedLines;
@ -2505,5 +2507,54 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
setAspectRatio11ToolStripMenuItem_Click(null, null);
}
}
private void ChangeBrightness(bool onlySelectedLines)
{
if (subtitleListView1.SelectedItems.Count < 1)
{
return;
}
var idx = subtitleListView1.SelectedItems[0].Index;
var extra = _extra[idx];
var bmp = extra.Bitmap != null ? (Bitmap)extra.Bitmap.Clone() : GetBitmap(_binSubtitles[idx]);
using (var form = new BinEditBrightness(bmp))
{
if (form.ShowDialog(this) != DialogResult.OK)
{
return;
}
var selectedIndices = GetIndices(onlySelectedLines);
foreach (var i in selectedIndices)
{
var sub = _binSubtitles[i];
extra = _extra[i];
bmp = extra.Bitmap != null ? (Bitmap)extra.Bitmap.Clone() : GetBitmap(sub);
var n = new NikseBitmap(bmp);
n.ChangeBrightness(form.Factor);
extra.Bitmap = n.GetBitmap();
if (i == idx)
{
ShowCurrentScaledImage((Bitmap)extra.Bitmap.Clone(), extra);
numericUpDownY.Value = extra.Y;
numericUpDownX.Value = extra.X;
}
bmp.Dispose();
}
}
}
private void changeBrightnessToolStripMenuItem_Click(object sender, EventArgs e)
{
ChangeBrightness(false);
}
private void changeBrightnessForSelectedLinesToolStripMenuItem_Click(object sender, EventArgs e)
{
ChangeBrightness(true);
}
}
}

View File

@ -0,0 +1,133 @@

namespace Nikse.SubtitleEdit.Forms.BinaryEdit
{
partial class BinEditBrightness
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.trackBarBrightness = new System.Windows.Forms.TrackBar();
this.pictureBoxPreview = new System.Windows.Forms.PictureBox();
this.labelChangeBrightness = new System.Windows.Forms.Label();
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).BeginInit();
this.SuspendLayout();
//
// trackBarBrightness
//
this.trackBarBrightness.Location = new System.Drawing.Point(12, 51);
this.trackBarBrightness.Maximum = 200;
this.trackBarBrightness.Minimum = 10;
this.trackBarBrightness.Name = "trackBarBrightness";
this.trackBarBrightness.Size = new System.Drawing.Size(429, 45);
this.trackBarBrightness.TabIndex = 0;
this.trackBarBrightness.TickStyle = System.Windows.Forms.TickStyle.None;
this.trackBarBrightness.Value = 100;
this.trackBarBrightness.Scroll += new System.EventHandler(this.trackBarBrightness_Scroll);
//
// pictureBoxPreview
//
this.pictureBoxPreview.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)));
this.pictureBoxPreview.Location = new System.Drawing.Point(6, 102);
this.pictureBoxPreview.Name = "pictureBoxPreview";
this.pictureBoxPreview.Size = new System.Drawing.Size(832, 161);
this.pictureBoxPreview.TabIndex = 1;
this.pictureBoxPreview.TabStop = false;
//
// labelChangeBrightness
//
this.labelChangeBrightness.AutoSize = true;
this.labelChangeBrightness.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.labelChangeBrightness.Location = new System.Drawing.Point(12, 30);
this.labelChangeBrightness.Name = "labelChangeBrightness";
this.labelChangeBrightness.Size = new System.Drawing.Size(145, 18);
this.labelChangeBrightness.TabIndex = 2;
this.labelChangeBrightness.Text = "Brightness - 100%";
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(685, 269);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 8;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(769, 269);
this.buttonCancel.MinimumSize = new System.Drawing.Size(75, 23);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 9;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// BinEditBrightness
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(856, 304);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.labelChangeBrightness);
this.Controls.Add(this.pictureBoxPreview);
this.Controls.Add(this.trackBarBrightness);
this.KeyPreview = true;
this.MinimumSize = new System.Drawing.Size(500, 343);
this.Name = "BinEditBrightness";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "BinEditResize";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.BinEditBrightness_KeyDown);
((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TrackBar trackBarBrightness;
private System.Windows.Forms.PictureBox pictureBoxPreview;
private System.Windows.Forms.Label labelChangeBrightness;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonCancel;
}
}

View File

@ -0,0 +1,68 @@
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Logic;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Nikse.SubtitleEdit.Forms.BinaryEdit
{
public partial class BinEditBrightness : Form
{
private readonly Bitmap _bitmap;
public decimal Factor { get; private set; }
public ContentAlignment Alignment { get; private set; }
public BinEditBrightness(Bitmap bitmap)
{
UiUtil.PreInitialize(this);
InitializeComponent();
UiUtil.FixFonts(this);
_bitmap = bitmap;
trackBarBrightness_Scroll(null, null);
Factor = 1.0m;
Alignment = ContentAlignment.BottomCenter;
Text = LanguageSettings.Current.BinEdit.ChangeBrightnessTitle;
labelChangeBrightness.Text = string.Format(LanguageSettings.Current.BinEdit.BrightnessX, trackBarBrightness.Value);
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
UiUtil.FixLargeFonts(this, buttonOK);
}
private void trackBarBrightness_Scroll(object sender, EventArgs e)
{
Factor = trackBarBrightness.Value / 100.0m;
labelChangeBrightness.Text = string.Format(LanguageSettings.Current.BinEdit.BrightnessX, trackBarBrightness.Value);
var bmp = ChangeBrightness(_bitmap, Factor);
pictureBoxPreview.Image?.Dispose();
pictureBoxPreview.Image = bmp;
}
public static Bitmap ChangeBrightness(Bitmap bitmap, decimal factor)
{
var n = new NikseBitmap(bitmap);
n.ChangeBrightness(factor);
return n.GetBitmap();
}
private void BinEditBrightness_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
DialogResult = DialogResult.Cancel;
}
}
private void buttonOK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -39,6 +39,9 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
SetFontSize();
_loading = false;
textBoxText.Text = text;
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
UiUtil.FixLargeFonts(this, buttonOK);
}

View File

@ -50,6 +50,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
this.trackBarResize.Name = "trackBarResize";
this.trackBarResize.Size = new System.Drawing.Size(429, 45);
this.trackBarResize.TabIndex = 0;
this.trackBarResize.TickStyle = System.Windows.Forms.TickStyle.None;
this.trackBarResize.Value = 100;
this.trackBarResize.Scroll += new System.EventHandler(this.trackBarResize_Scroll);
//

View File

@ -1,5 +1,4 @@
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic;
using System;
using System.Drawing;
using System.Windows.Forms;
@ -26,13 +25,18 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit
FixAlignment = true;
Alignment = ContentAlignment.BottomCenter;
checkBoxFixAlignment.Checked = true;
Text = LanguageSettings.Current.BinEdit.ResizeTitle;
labelResize.Text = string.Format(LanguageSettings.Current.BinEdit.ResizeX, trackBarResize.Value);
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
UiUtil.FixLargeFonts(this, buttonOK);
}
private void trackBarResize_Scroll(object sender, EventArgs e)
{
Factor = trackBarResize.Value / 100.0m;
labelResize.Text = "Resize in % - " + trackBarResize.Value + "%";
labelResize.Text = string.Format(LanguageSettings.Current.BinEdit.ResizeX, trackBarResize.Value);
var bmp = ExportPngXml.ResizeBitmap(_bitmap, (int)Math.Round(_bitmap.Width * Factor), (int)Math.Round(_bitmap.Height * Factor));
pictureBoxResized.Image?.Dispose();
pictureBoxResized.Image = bmp;

View File

@ -392,14 +392,20 @@ namespace Nikse.SubtitleEdit.Logic
SetText = "Set text...",
QuickOcr = "Quick OCR texts (for overview only)",
ResizeBitmaps = "Resize images...",
ChangeBrightness = "Change brightness...",
ResizeBitmapsForSelectedLines = "Resize images for selected lines...",
ChangeColorForSelectedLines = "Change color for selected lines...",
ChangeBrightnessForSelectedLines = "Change brightness for selected lines...",
AlignSelectedLines = "Align selected lines",
CenterSelectedLines = "Center selected lines (horizontally, keep vertical position)",
TopAlignSelectedLines = "Top align selected lines (keep horizontal position)",
BottomAlignSelectedLines = "Bottom align selected lines (keep horizontal position)",
SizeXY = "Size: {0}x{1}",
SetAspectRatio11 = "Set aspect ratio 1:1",
ChangeBrightnessTitle = "Change brightness",
BrightnessX = "Brightness: {0}%",
ResizeTitle = "Resize images",
ResizeX = "Resize: {0}%",
};
Bookmarks = new LanguageStructure.Bookmarks

View File

@ -670,12 +670,18 @@ namespace Nikse.SubtitleEdit.Logic
case "BinEdit/ResizeBitmaps":
language.BinEdit.ResizeBitmaps = reader.Value;
break;
case "BinEdit/ChangeBrightness":
language.BinEdit.ChangeBrightness = reader.Value;
break;
case "BinEdit/ResizeBitmapsForSelectedLines":
language.BinEdit.ResizeBitmapsForSelectedLines = reader.Value;
break;
case "BinEdit/ChangeColorForSelectedLines":
language.BinEdit.ChangeColorForSelectedLines = reader.Value;
break;
case "BinEdit/ChangeBrightnessForSelectedLines":
language.BinEdit.ChangeBrightnessForSelectedLines = reader.Value;
break;
case "BinEdit/AlignSelectedLines":
language.BinEdit.AlignSelectedLines = reader.Value;
break;
@ -694,6 +700,18 @@ namespace Nikse.SubtitleEdit.Logic
case "BinEdit/SetAspectRatio11":
language.BinEdit.SetAspectRatio11 = reader.Value;
break;
case "BinEdit/ChangeBrightnessTitle":
language.BinEdit.ChangeBrightnessTitle = reader.Value;
break;
case "BinEdit/BrightnessX":
language.BinEdit.BrightnessX = reader.Value;
break;
case "BinEdit/ResizeTitle":
language.BinEdit.ResizeTitle = reader.Value;
break;
case "BinEdit/ResizeX":
language.BinEdit.ResizeX = reader.Value;
break;
case "Bookmarks/EditBookmark":
language.Bookmarks.EditBookmark = reader.Value;
break;

View File

@ -261,14 +261,20 @@
public string SetText { get; set; }
public string QuickOcr { get; set; }
public string ResizeBitmaps { get; set; }
public string ChangeBrightness { get; set; }
public string ResizeBitmapsForSelectedLines { get; set; }
public string ChangeColorForSelectedLines { get; set; }
public string ChangeBrightnessForSelectedLines { get; set; }
public string AlignSelectedLines { get; set; }
public string CenterSelectedLines { get; set; }
public string TopAlignSelectedLines { get; set; }
public string BottomAlignSelectedLines { get; set; }
public string SizeXY { get; set; }
public string SetAspectRatio11 { get; set; }
public string ChangeBrightnessTitle { get; set; }
public string BrightnessX { get; set; }
public string ResizeTitle { get; set; }
public string ResizeX { get; set; }
}
public class Bookmarks

View File

@ -136,6 +136,12 @@
<Compile Include="Forms\BinaryEdit\BinEditNewText.Designer.cs">
<DependentUpon>BinEditNewText.cs</DependentUpon>
</Compile>
<Compile Include="Forms\BinaryEdit\BinEditBrightness.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\BinaryEdit\BinEditBrightness.Designer.cs">
<DependentUpon>BinEditBrightness.cs</DependentUpon>
</Compile>
<Compile Include="Forms\BinaryEdit\BinEditResize.cs">
<SubType>Form</SubType>
</Compile>
@ -1200,6 +1206,9 @@
<EmbeddedResource Include="Forms\BinaryEdit\BinEditNewText.resx">
<DependentUpon>BinEditNewText.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\BinaryEdit\BinEditBrightness.resx">
<DependentUpon>BinEditBrightness.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\BinaryEdit\BinEditResize.resx">
<DependentUpon>BinEditResize.cs</DependentUpon>
</EmbeddedResource>