summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SpriteEd/NSSpriteEdit.cs26
1 files changed, 19 insertions, 7 deletions
diff --git a/SpriteEd/NSSpriteEdit.cs b/SpriteEd/NSSpriteEdit.cs
index 53e9ab3..27a67c3 100644
--- a/SpriteEd/NSSpriteEdit.cs
+++ b/SpriteEd/NSSpriteEdit.cs
@@ -198,19 +198,25 @@ namespace SpriteEd
get
{
uint bx = m_sprite.Width * (DoubleWidth ? 2u : 1u);
+ uint by = m_sprite.Height * (DoubleHeight ? 2u : 1u);
uint s = (uint)Math.Min(Frame.Width, Frame.Height);
+ uint dx = s/bx;
+ uint dy = s/by;
+
+ uint min = Math.Min(dx, dy);
+
if (!(DoubleWidth ^ DoubleHeight))
{
- return s/bx * (DoubleWidth ? 2u : 1u);
+ return min * (DoubleWidth ? 2u : 1u);
}
else if (DoubleWidth)
{
- return s/bx * 2u;
+ return min * 2u;
}
else
{
- return s/bx / 2u;
+ return min;
}
}
}
@@ -222,20 +228,26 @@ namespace SpriteEd
{
get
{
+ uint bx = m_sprite.Width * (DoubleWidth ? 2u : 1u);
uint by = m_sprite.Height * (DoubleHeight ? 2u : 1u);
uint s = (uint)Math.Min(Frame.Width, Frame.Height);
+ uint dx = s/bx;
+ uint dy = s/by;
+
+ uint min = Math.Min(dx, dy);
+
if (!(DoubleWidth ^ DoubleHeight))
{
- return s/by * (DoubleHeight ? 2u : 1u);
+ return min * (DoubleWidth ? 2u : 1u);
}
- else if (DoubleWidth)
+ else if (DoubleHeight)
{
- return s/by / 2u;
+ return min * 2u;
}
else
{
- return s/by * 2u;
+ return min;
}
}
}