mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Fix for crash due to color in karoke/typewriter effect - thx PM :)
This commit is contained in:
parent
ae249cbf14
commit
a3963cc60c
@ -37,7 +37,7 @@
|
||||
* Make "load second subtitle" work with more subtitle formats - thx PM
|
||||
* Improve compare colors for dark theme - thx OmrSi
|
||||
* Minor UI improvements for nOCR character inspect
|
||||
* Add "Clear" to File - Recent files - thx Dominiquini/OmrSi
|
||||
* Add "Clear" to "File - Recent files" - thx Dominiquini/OmrSi
|
||||
* Make bd sup edit work better with full frame images - thx peter-qgd
|
||||
* Point sync now also works on original subtitle - thx Rene
|
||||
* FIXED:
|
||||
@ -52,6 +52,7 @@
|
||||
* Some fixes for editing source view - thx PreetM07
|
||||
* Fix bug converting vtt two line color text to srt
|
||||
* Fix FCE issue w missing spaces/French language - thx kyrpasto/OmrSi
|
||||
* Fix crash in karoke/typewriter effect due to invalid color - thx PM
|
||||
|
||||
|
||||
3.6.0 (18th February 2021)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@ -909,5 +910,28 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
return text;
|
||||
}
|
||||
|
||||
public static Color GetColorFromString(string color)
|
||||
{
|
||||
Color c = Color.White;
|
||||
try
|
||||
{
|
||||
if (color.StartsWith("rgb(", StringComparison.Ordinal))
|
||||
{
|
||||
string[] arr = color.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
c = ColorTranslator.FromHtml(color);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -442,23 +442,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
|
||||
color = node.Attributes["tts:color"].Value.Trim();
|
||||
}
|
||||
|
||||
Color c = Color.White;
|
||||
try
|
||||
{
|
||||
if (color.StartsWith("rgb(", StringComparison.Ordinal))
|
||||
{
|
||||
string[] arr = color.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
c = ColorTranslator.FromHtml(color);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
var c = HtmlUtil.GetColorFromString(color);
|
||||
|
||||
string fontSize = "20";
|
||||
if (node.Attributes["tts:fontSize"] != null)
|
||||
@ -589,23 +573,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
|
||||
color = node.Attributes["tts:color"].Value.Trim();
|
||||
}
|
||||
|
||||
Color c = Color.White;
|
||||
try
|
||||
{
|
||||
if (color.StartsWith("rgb(", StringComparison.Ordinal))
|
||||
{
|
||||
string[] arr = color.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
c = ColorTranslator.FromHtml(color);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
var c = HtmlUtil.GetColorFromString(color);
|
||||
|
||||
string fontSize = "20";
|
||||
if (node.Attributes["tts:fontSize"] != null)
|
||||
@ -802,15 +770,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
|
||||
string subTag = fontTag.Substring(fontStart + tag.Length, fontEnd - (fontStart + tag.Length));
|
||||
if (tag.Contains("color"))
|
||||
{
|
||||
Color c;
|
||||
try
|
||||
{
|
||||
c = ColorTranslator.FromHtml(subTag);
|
||||
}
|
||||
catch
|
||||
{
|
||||
c = Color.White;
|
||||
}
|
||||
var c = HtmlUtil.GetColorFromString(subTag);
|
||||
subTag = (c.B.ToString("X2") + c.G.ToString("X2") + c.R.ToString("X2")).ToLowerInvariant(); // use bbggrr
|
||||
}
|
||||
fontTag = fontTag.Remove(fontStart, fontEnd - fontStart + 1);
|
||||
|
@ -194,7 +194,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
int length = rtb.Text.Length;
|
||||
richTextBoxPreview.Text += text;
|
||||
_colorList.Add(new ColorEntry { Start = length, Length = text.Length, Color = string.IsNullOrWhiteSpace(color) ? Color.White : ColorTranslator.FromHtml(color) });
|
||||
_colorList.Add(new ColorEntry { Start = length, Length = text.Length, Color = HtmlUtil.GetColorFromString(color) });
|
||||
|
||||
var fontStyle = new FontStyle();
|
||||
if (underline)
|
||||
|
@ -176,21 +176,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var c = Color.White;
|
||||
if (!string.IsNullOrWhiteSpace(color))
|
||||
{
|
||||
try
|
||||
{
|
||||
c = ColorTranslator.FromHtml(color);
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
c = ColorTranslator.FromHtml("#" + color.Trim('#', ' ', '"', '\''));
|
||||
}
|
||||
catch
|
||||
{
|
||||
c = Color.White;
|
||||
}
|
||||
}
|
||||
c = HtmlUtil.GetColorFromString(color);
|
||||
}
|
||||
|
||||
_colorList.Add(new EffectKaraoke.ColorEntry { Start = length, Length = text.Length, Color = c });
|
||||
|
Loading…
Reference in New Issue
Block a user