Fix Palette trying to create 0px bitmaps

Caused by using Math.round when scaling down.
Fixed by using Math.ceil instead.

BUG: 25263397
Change-Id: Iefe82fa9d085fb72d2dfae4c984ebd836c5ad8c5
diff --git a/v7/palette/src/androidTest/java/android/support/v7/graphics/BucketTests.java b/v7/palette/src/androidTest/java/android/support/v7/graphics/BucketTests.java
index 69c6735..3635c3e 100644
--- a/v7/palette/src/androidTest/java/android/support/v7/graphics/BucketTests.java
+++ b/v7/palette/src/androidTest/java/android/support/v7/graphics/BucketTests.java
@@ -106,4 +106,32 @@
         }
         assertNull(thrown);
     }
+
+    public void testOnePixelTallBitmap() {
+        Bitmap bitmap = Bitmap.createBitmap(1000, 1, Bitmap.Config.ARGB_8888);
+
+        Palette.Builder b = new Palette.Builder(bitmap);
+
+        Throwable thrown = null;
+        try {
+            b.generate();
+        } catch (Exception e) {
+            thrown = e;
+        }
+        assertNull(thrown);
+    }
+
+    public void testOnePixelWideBitmap() {
+        Bitmap bitmap = Bitmap.createBitmap(1, 1000, Bitmap.Config.ARGB_8888);
+
+        Palette.Builder b = new Palette.Builder(bitmap);
+
+        Throwable thrown = null;
+        try {
+            b.generate();
+        } catch (Exception e) {
+            thrown = e;
+        }
+        assertNull(thrown);
+    }
 }
diff --git a/v7/palette/src/main/java/android/support/v7/graphics/Palette.java b/v7/palette/src/main/java/android/support/v7/graphics/Palette.java
index 243bc8f..57f34a6 100644
--- a/v7/palette/src/main/java/android/support/v7/graphics/Palette.java
+++ b/v7/palette/src/main/java/android/support/v7/graphics/Palette.java
@@ -280,10 +280,10 @@
             return bitmap;
         }
 
-        final float scaleRatio = targetMaxDimension / (float) maxDimension;
+        final double scaleRatio = targetMaxDimension / (double) maxDimension;
         return Bitmap.createScaledBitmap(bitmap,
-                Math.round(bitmap.getWidth() * scaleRatio),
-                Math.round(bitmap.getHeight() * scaleRatio),
+                (int) Math.ceil(bitmap.getWidth() * scaleRatio),
+                (int) Math.ceil(bitmap.getHeight() * scaleRatio),
                 false);
     }