@Test public void onlyScaleDownOriginalSmaller() { Bitmap source = Bitmap.createBitmap(50, 50, ARGB_8888); Request data = new Request.Builder(URI_1).resize(100, 100).onlyScaleDown().build(); Bitmap result = transformResult(data, source, 0); assertThat(result).isSameAs(source); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isNull(); assertThat(shadowBitmap.getCreatedFromBitmap()).isNotSameAs(source); }
@Test public void onlyScaleDownOriginalSmallerWidthIs0() { Bitmap source = Bitmap.createBitmap(50, 50, ARGB_8888); Request data = new Request.Builder(URI_1).resize(0, 60).onlyScaleDown().build(); Bitmap result = transformResult(data, source, 0); assertThat(result).isSameAs(source); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isNull(); }
@Test public void onlyScaleDownOriginalSmallerHeightIs0() { Bitmap source = Bitmap.createBitmap(50, 50, ARGB_8888); Request data = new Request.Builder(URI_1).resize(60, 0).onlyScaleDown().build(); Bitmap result = transformResult(data, source, 0); assertThat(result).isSameAs(source); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isNull(); }
@Test public void exifRotationNoSizing() { Request data = new Request.Builder(URI_1).build(); Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Bitmap result = transformResult(data, source, ORIENTATION_ROTATE_90); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).contains("rotate 90.0"); }
@Test public void exifRotationSizing() { Request data = new Request.Builder(URI_1).resize(5, 10).build(); Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Bitmap result = transformResult(data, source, ORIENTATION_ROTATE_90); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).contains("scale 1.0 0.5"); }
@Test public void exifTransverse() { Request data = new Request.Builder(URI_1).rotate(-45).build(); Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Bitmap result = transformResult(data, source, ORIENTATION_TRANSVERSE); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPostOperations()).containsExactly("scale -1.0 1.0"); assertThat(shadowMatrix.getPreOperations()).containsExactly("rotate 270.0"); }
@Test public void rotation() { Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Request data = new Request.Builder(URI_1).rotate(-45).build(); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getSetOperations()).containsEntry("rotate", "-45.0"); }
@Test public void pivotRotation() { Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Request data = new Request.Builder(URI_1).rotate(-45, 10, 10).build(); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getSetOperations()).containsEntry("rotate", "-45.0 10.0 10.0"); }
@Test public void exifRotation() { Request data = new Request.Builder(URI_1).rotate(-45).build(); Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Bitmap result = transformResult(data, source, ORIENTATION_ROTATE_90); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).containsExactly("rotate 90.0"); }
@Test public void resize() { Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Request data = new Request.Builder(URI_1).resize(20, 15).build(); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 2.0 1.5"); }
@Test public void exifTranspose() { Request data = new Request.Builder(URI_1).rotate(-45).build(); Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Bitmap result = transformResult(data, source, ORIENTATION_TRANSPOSE); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPostOperations()).containsExactly("scale -1.0 1.0"); assertThat(shadowMatrix.getPreOperations()).containsExactly("rotate 90.0"); }
@Test public void rotation90WithPivotSizing() { Request data = new Request.Builder(URI_1).rotate(90,0,10).resize(5, 10).build(); Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).contains("scale 1.0 0.5"); }
@Test public void rotation180Sizing() { Request data = new Request.Builder(URI_1).rotate(180).resize(5, 10).build(); Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).contains("scale 0.5 1.0"); }
@Test public void onlyScaleDownOriginalBiggerWidthIs0() { Bitmap source = Bitmap.createBitmap(50, 50, ARGB_8888); Request data = new Request.Builder(URI_1).resize(0, 40).onlyScaleDown().build(); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 0.8 0.8"); }
@Test public void rotation90Sizing() { Request data = new Request.Builder(URI_1).rotate(90).resize(5, 10).build(); Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).contains("scale 1.0 0.5"); }
@Test public void centerInsideTallTooSmall() { Bitmap source = Bitmap.createBitmap(20, 10, ARGB_8888); Request data = new Request.Builder(URI_1).resize(50, 50).centerInside().build(); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 2.5 2.5"); }
@Test public void centerInsideWideTooSmall() { Bitmap source = Bitmap.createBitmap(10, 20, ARGB_8888); Request data = new Request.Builder(URI_1).resize(50, 50).centerInside().build(); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 2.5 2.5"); }
@Test public void onlyScaleDownOriginalBigger() { Bitmap source = Bitmap.createBitmap(100, 100, ARGB_8888); Request data = new Request.Builder(URI_1).resize(50, 50).onlyScaleDown().build(); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 0.5 0.5"); }
@Test public void onlyScaleDownOriginalBiggerHeightIs0() { Bitmap source = Bitmap.createBitmap(50, 50, ARGB_8888); Request data = new Request.Builder(URI_1).resize(40, 0).onlyScaleDown().build(); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 0.8 0.8"); }
@Test public void centerInsideTallTooLarge() { Bitmap source = Bitmap.createBitmap(100, 50, ARGB_8888); Request data = new Request.Builder(URI_1).resize(50, 50).centerInside().build(); Bitmap result = transformResult(data, source, 0); ShadowBitmap shadowBitmap = shadowOf(result); assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source); Matrix matrix = shadowBitmap.getCreatedFromMatrix(); ShadowMatrix shadowMatrix = shadowOf(matrix); assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 0.5 0.5"); }