summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2020-07-14 20:53:40 +0000
committerIan C <ianc@noddybox.co.uk>2020-07-14 20:53:40 +0000
commit801926dcf4444621516a0979f7a70135cd756f32 (patch)
tree54a52fc13e290b4c5c3133c522d1500d0ae00fae
parent4db4c52518c5b3bf1f7fd1a33d03bc9a6f69fd4b (diff)
Fixed block size calculations.
-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;
}
}
}