Skip to content

Commit

Permalink
Correct scaling for preview image.
Browse files Browse the repository at this point in the history
  • Loading branch information
MainMemory committed May 20, 2015
1 parent c7efee4 commit 99b0e4f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion SonicBGScrollSaver/MainForm.cs
Expand Up @@ -14,6 +14,7 @@ public partial class MainForm : Form
bool previewMode;
Rectangle bounds;
Size imageSize;
double previewScale;

public MainForm()
{
Expand All @@ -40,11 +41,13 @@ public MainForm(IntPtr previewWndHandle)
{
imageSize.Width = (int)(bounds.Width * ((double)scrnSize.Height / bounds.Height));
imageSize.Height = scrnSize.Height;
previewScale = (double)bounds.Height / scrnSize.Height;
}
else
{
imageSize.Width = scrnSize.Width;
imageSize.Height = (int)(bounds.Height * ((double)scrnSize.Width / bounds.Width));
previewScale = (double)bounds.Width / scrnSize.Width;
}
previewMode = true;
}
Expand Down Expand Up @@ -134,7 +137,8 @@ void DrawBackground()

void DrawBackgroundPreview()
{
BackgroundImage = new Bitmap(level.GetBG(), Width, Height);
Bitmap tmp = level.GetBG();
BackgroundImage = new Bitmap(tmp, (int)(tmp.Width * previewScale), (int)(tmp.Height * previewScale));
}

void SwitchTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
Expand Down

0 comments on commit 99b0e4f

Please sign in to comment.