Skip to content

Commit

Permalink
Fix badges and bits not obeying custom scaling when the font size is …
Browse files Browse the repository at this point in the history
…set to 24 (#975)
  • Loading branch information
ScrubN committed Feb 24, 2024
1 parent b03fc6f commit df17b5b
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions TwitchDownloaderCore/ChatRenderer.cs
Expand Up @@ -1628,11 +1628,11 @@ private async Task<List<ChatBadge>> 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;
Expand All @@ -1644,12 +1644,12 @@ private async Task<List<TwitchEmote>> 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<byte>(); // Clear the image byte[] as we aren't embedding to an output file
}

return emoteTask;
Expand All @@ -1662,12 +1662,12 @@ private async Task<List<TwitchEmote>> 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<byte>(); // Clear the image byte[] as we aren't embedding to an output file
}

return emoteThirdTask;
Expand All @@ -1680,14 +1680,10 @@ private async Task<List<CheerEmote>> 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<byte>(); // Clear the image byte[]s as we aren't embedding to an output file
cheer.Resize(newScale);
}
}

Expand Down

0 comments on commit df17b5b

Please sign in to comment.