aboutsummaryrefslogtreecommitdiffstats
path: root/assetstudio/src/com/android/assetstudiolib/Util.java
diff options
context:
space:
mode:
Diffstat (limited to 'assetstudio/src/com/android/assetstudiolib/Util.java')
-rw-r--r--assetstudio/src/com/android/assetstudiolib/Util.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/assetstudio/src/com/android/assetstudiolib/Util.java b/assetstudio/src/com/android/assetstudiolib/Util.java
index 82299a4..1a6b00e 100644
--- a/assetstudio/src/com/android/assetstudiolib/Util.java
+++ b/assetstudio/src/com/android/assetstudiolib/Util.java
@@ -325,8 +325,8 @@ public class Util {
final int srcWidth = source.getWidth();
final int srcHeight = source.getHeight();
if (srcWidth * 1.0 / srcHeight > dstRect.width * 1.0 / dstRect.height) {
- final int scaledWidth = dstRect.width;
- final int scaledHeight = dstRect.width * srcHeight / srcWidth;
+ final int scaledWidth = Math.max(1, dstRect.width);
+ final int scaledHeight = Math.max(1, dstRect.width * srcHeight / srcWidth);
Image scaledImage = scaledImage(source, scaledWidth, scaledHeight);
g.drawImage(scaledImage,
dstRect.x,
@@ -339,8 +339,8 @@ public class Util {
0 + scaledHeight,
null);
} else {
- final int scaledWidth = dstRect.height * srcWidth / srcHeight;
- final int scaledHeight = dstRect.height;
+ final int scaledWidth = Math.max(1, dstRect.height * srcWidth / srcHeight);
+ final int scaledHeight = Math.max(1, dstRect.height);
Image scaledImage = scaledImage(source, scaledWidth, scaledHeight);
g.drawImage(scaledImage,
dstRect.x + (dstRect.width - scaledWidth) / 2,