Skip to content

Commit

Permalink
Allow intermediate scaling step in Sharp Billinear grow more than the…
Browse files Browse the repository at this point in the history
… final size

Should slightly improve quality when the intermediate step is closer to the next scale factor than a floor would have
  • Loading branch information
CasualPokePlayer committed Dec 2, 2024
1 parent 6d2618d commit f2913ea
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions GSE/PostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,17 @@ private void CalculateScaledRect(in SDL_Rect srcRect, ref SDL_Rect dstRect, bool

if (integerScaleOnly)
{
var scaleW = Math.Max(dstWidth / srcWidth, 1);
var scaleH = Math.Max(dstHeight / srcHeight, 1);
var scaleW = Math.Max((int)Math.Round(dstWidth / (double)srcWidth, MidpointRounding.AwayFromZero), 1);
var scaleH = Math.Max((int)Math.Round(dstHeight / (double)srcHeight, MidpointRounding.AwayFromZero), 1);
if (config.KeepAspectRatio)
{
var scale = Math.Min(scaleW, scaleH);
scaleW = scale;
scaleH = scale;
}

// this can make the dstRect "grow"
// but that's fine here, as the intermediate texture will grow accordingly
dstWidth = srcWidth * scaleW;
dstHeight = srcHeight * scaleH;

Expand Down

0 comments on commit f2913ea

Please sign in to comment.