Fixed scaling

This commit is contained in:
Flamefire committed 2013-04-18 12:37:25 +02:00
1 parent eb71c1158e
commit 2dc2ac5c37
1 file changed
+21 -15
+21 -15
View File
@@ -919,29 +919,35 @@ namespace Vocaluxe.Lib.Draw
int w = bmp.Width;
int h = bmp.Height;
float ratio = (float)w / h;
int newW = w;
int newH = h;
if (w > maxSize && w > h)
{
h = (int)Math.Round((float)maxSize / bmp.Width * bmp.Height);
w = maxSize;
}
if (h > maxSize)
{
w = (int)Math.Round((float)maxSize / bmp.Height * bmp.Width);
h = maxSize;
}
//Older graphics card can only handle textures with sizes being powers of two
w = (int)_CheckForNextPowerOf2(w);
h = (int)_CheckForNextPowerOf2(h);
newW = maxSize;
else if (h > maxSize)
newH = maxSize;
else if (w > h)
newW = (int)_CheckForNextPowerOf2(w);
else
newH = (int)_CheckForNextPowerOf2(h);
Bitmap bmp2 = null;
byte[] data;
try
{
if (w != bmp.Width || h != bmp.Height)
if (w != newW || h != newH)
{
if (w != newW)
{
w = newW;
h = (int)Math.Round(w / ratio);
}
else
{
h = newH;
w = (int)Math.Round(h * ratio);
}
//Create a new Bitmap with the new sizes
bmp2 = new Bitmap(w, h);
//Scale the texture