From eb814ea20a6612aedbae77ff3ed137721db4f42e Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Sun, 22 Jan 2017 11:52:36 +0100 Subject: [PATCH] Fixed bug in image export - thx marb99 :) Fix #2187 --- Changelog.txt | 2 + src/Forms/ExportPngXml.cs | 78 ++++++++++++--------------------------- 2 files changed, 26 insertions(+), 54 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index d32973975..beb3d6591 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,7 @@ * Added shortcut "Go to previous line and set video position" - thx Mia * IMPROVED: * Updated Russian translation - thx Elheym + * Updated Portuguese translation - thx moob * Minor improvements for format "Structured titles" - thx Yamato-ua * List view columns arrangable and non-clickable - thx Ingo * FIXED: @@ -18,6 +19,7 @@ * Fix for MPC-HC 32-bit - thx ZoneX * Fixed issue with importing "Unknown 53" format - thx darnn * Fixed italic rendering issue in format DCinema SMPTE - thx Miga + * Fixed bug in image export - thx marb99 3.5.1 (13th December 2016) diff --git a/src/Forms/ExportPngXml.cs b/src/Forms/ExportPngXml.cs index db4578dbd..bd3cc5908 100644 --- a/src/Forms/ExportPngXml.cs +++ b/src/Forms/ExportPngXml.cs @@ -1951,15 +1951,8 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + lastText.Append(sb); TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); } - if (path.PointCount > 0) - { - var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! - for (int k = oldPathPointIndex; k < list.Length; k++) - { - if (list[k].X > addLeft) - addLeft = list[k].X; - } - } + + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); if (path.PointCount == 0) addLeft = left; else if (addLeft < 0.01) @@ -2068,15 +2061,8 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); } - if (path.PointCount > 0) - { - var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! - for (int k = oldPathPointIndex; k < list.Length; k++) - { - if (list[k].X > addLeft) - addLeft = list[k].X; - } - } + + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); if (addLeft < 0.01) addLeft = left + 2; left = addLeft; @@ -2563,15 +2549,8 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + lastText.Append(sb); TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); } - if (path.PointCount > 0) - { - var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! - for (int k = oldPathPointIndex; k < list.Length; k++) - { - if (list[k].X > addLeft) - addLeft = list[k].X; - } - } + + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); if (path.PointCount == 0) addLeft = left; else if (addLeft < 0.01) @@ -2682,15 +2661,8 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); } - if (path.PointCount > 0) - { - var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! - for (int k = oldPathPointIndex; k < list.Length; k++) - { - if (list[k].X > addLeft) - addLeft = list[k].X; - } - } + + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); if (addLeft < 0.01) addLeft = left + 2; left = addLeft; @@ -2745,15 +2717,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); } - if (path.PointCount > 0) - { - var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! - for (int k = oldPathPointIndex; k < list.Length; k++) - { - if (list[k].X > addLeft) - addLeft = list[k].X; - } - } + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); if (addLeft < 0.01) addLeft = left + 2; left = addLeft; @@ -2797,15 +2761,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); } - if (path.PointCount > 0) - { - var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! - for (int k = oldPathPointIndex; k < list.Length; k++) - { - if (list[k].X > addLeft) - addLeft = list[k].X; - } - } + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); if (addLeft < 0.01) addLeft = left + 2; left = addLeft; @@ -2908,6 +2864,20 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + } } + private static float GetLastPositionFromPath(GraphicsPath path, int oldPathPointIndex, float addLeft) + { + if (path.PointCount > 0) + { + var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! + for (int k = oldPathPointIndex + 1; k < list.Length; k++) + { + if (list[k].X > addLeft) + addLeft = list[k].X; + } + } + return addLeft; + } + private static Point? GetAssPoint(string s) { int k = s.IndexOf("{\\", StringComparison.Ordinal);