From df17b5b4e561f1c927d3fda765d67c618171715e Mon Sep 17 00:00:00 2001 From: Scrub <72096833+ScrubN@users.noreply.github.com> Date: Sat, 24 Feb 2024 18:44:14 -0500 Subject: [PATCH] Fix badges and bits not obeying custom scaling when the font size is set to 24 (#975) --- TwitchDownloaderCore/ChatRenderer.cs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/TwitchDownloaderCore/ChatRenderer.cs b/TwitchDownloaderCore/ChatRenderer.cs index 850aec93..1ed581e2 100644 --- a/TwitchDownloaderCore/ChatRenderer.cs +++ b/TwitchDownloaderCore/ChatRenderer.cs @@ -1628,11 +1628,11 @@ private async Task> GetScaledBadges(CancellationToken cancellati foreach (var badge in badgeTask) { // Assume badges are always 2x scale, not 1x or 4x - if (Math.Abs(renderOptions.ReferenceScale - 1.0) > 0.01) + var newScale = renderOptions.ReferenceScale * renderOptions.BadgeScale; + if (Math.Abs(newScale - 1.0) > 0.01) { - badge.Resize(renderOptions.ReferenceScale * renderOptions.BadgeScale); + badge.Resize(newScale); } - badge.VersionsData.Clear(); // Clear the image byte[]s as we aren't embedding to an output file } return badgeTask; @@ -1644,12 +1644,12 @@ private async Task> GetScaledEmotes(CancellationToken cancella foreach (var emote in emoteTask) { - double newScale = (2.0 / emote.ImageScale) * renderOptions.ReferenceScale * renderOptions.EmoteScale; + // Assume emojis are 4x scale + double newScale = emote.ImageScale * 0.5 * renderOptions.ReferenceScale * renderOptions.EmoteScale; if (Math.Abs(newScale - 1.0) > 0.01) { emote.Resize(newScale); } - emote.ImageData = Array.Empty(); // Clear the image byte[] as we aren't embedding to an output file } return emoteTask; @@ -1662,12 +1662,12 @@ private async Task> GetScaledThirdEmotes(CancellationToken can foreach (var emote in emoteThirdTask) { - double newScale = (2.0 / emote.ImageScale) * renderOptions.ReferenceScale * renderOptions.EmoteScale; + // Assume emojis are 4x scale + double newScale = emote.ImageScale * 0.5 * renderOptions.ReferenceScale * renderOptions.EmoteScale; if (Math.Abs(newScale - 1.0) > 0.01) { emote.Resize(newScale); } - emote.ImageData = Array.Empty(); // Clear the image byte[] as we aren't embedding to an output file } return emoteThirdTask; @@ -1680,14 +1680,10 @@ private async Task> GetScaledBits(CancellationToken cancellatio foreach (var cheer in cheerTask) { //Assume cheermotes are always 2x scale, not 1x or 4x - if (Math.Abs(renderOptions.ReferenceScale - 1.0) > 0.01) - { - cheer.Resize(renderOptions.ReferenceScale * renderOptions.EmoteScale); - } - - foreach (var tier in cheer.tierList) + var newScale = renderOptions.ReferenceScale * renderOptions.EmoteScale; + if (Math.Abs(newScale - 1.0) > 0.01) { - tier.Value.ImageData = Array.Empty(); // Clear the image byte[]s as we aren't embedding to an output file + cheer.Resize(newScale); } }