Java 类org.robolectric.shadows.ShadowBitmap 实例源码

项目:GitHub    文件:AttributeStrategyTest.java   
@Test
public void testLeastRecentlyUsedAttributeSetIsRemovedFirst() {
  final Bitmap leastRecentlyUsed = ShadowBitmap.createBitmap(100, 100, Bitmap.Config.ALPHA_8);
  final Bitmap other = ShadowBitmap.createBitmap(1000, 1000, Bitmap.Config.RGB_565);
  final Bitmap mostRecentlyUsed = ShadowBitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);

  strategy.get(100, 100, Bitmap.Config.ALPHA_8);
  strategy.get(1000, 1000, Bitmap.Config.RGB_565);
  strategy.get(100, 100, Bitmap.Config.ARGB_8888);

  strategy.put(other);
  strategy.put(leastRecentlyUsed);
  strategy.put(mostRecentlyUsed);

  Bitmap removed = strategy.removeLast();
  assertEquals(
      "Expected=" + strategy.logBitmap(leastRecentlyUsed) + " got=" + strategy.logBitmap(removed),
      leastRecentlyUsed, removed);
}
项目:GitHub    文件:AttributeStrategyTest.java   
@Test
public void testLeastRecentlyUsedAttributeSetIsRemovedFirst() {
  final Bitmap leastRecentlyUsed = ShadowBitmap.createBitmap(100, 100, Bitmap.Config.ALPHA_8);
  final Bitmap other = ShadowBitmap.createBitmap(1000, 1000, Bitmap.Config.RGB_565);
  final Bitmap mostRecentlyUsed = ShadowBitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);

  strategy.get(100, 100, Bitmap.Config.ALPHA_8);
  strategy.get(1000, 1000, Bitmap.Config.RGB_565);
  strategy.get(100, 100, Bitmap.Config.ARGB_8888);

  strategy.put(other);
  strategy.put(leastRecentlyUsed);
  strategy.put(mostRecentlyUsed);

  Bitmap removed = strategy.removeLast();
  assertEquals(
      "Expected=" + strategy.logBitmap(leastRecentlyUsed) + " got=" + strategy.logBitmap(removed),
      leastRecentlyUsed, removed);
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerCropResultMatchesTargetSize() {
  Request request = new Request.Builder(URI_1).resize(1080, 642).centerCrop().build();
  Bitmap source = Bitmap.createBitmap(640, 640, ARGB_8888);

  Bitmap result = transformResult(request, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  String scalePreOperation = shadowMatrix.getPreOperations().get(0);

  assertThat(scalePreOperation).startsWith("scale ");
  float scaleX = Float.valueOf(scalePreOperation.split(" ")[1]);
  float scaleY = Float.valueOf(scalePreOperation.split(" ")[2]);

  int transformedWidth = Math.round(result.getWidth() * scaleX);
  int transformedHeight = Math.round(result.getHeight() * scaleY);
  assertThat(transformedWidth).isEqualTo(1080);
  assertThat(transformedHeight).isEqualTo(642);
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerCropResultMatchesTargetSizeWhileDesiredWidthIs0() {
  Request request = new Request.Builder(URI_1).resize(0, 642).centerCrop().build();
  Bitmap source = Bitmap.createBitmap(640, 640, ARGB_8888);

  Bitmap result = transformResult(request, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  String scalePreOperation = shadowMatrix.getPreOperations().get(0);

  assertThat(scalePreOperation).startsWith("scale ");
  float scaleX = Float.valueOf(scalePreOperation.split(" ")[1]);
  float scaleY = Float.valueOf(scalePreOperation.split(" ")[2]);

  int transformedWidth = Math.round(result.getWidth() * scaleX);
  int transformedHeight = Math.round(result.getHeight() * scaleY);
  assertThat(transformedWidth).isEqualTo(642);
  assertThat(transformedHeight).isEqualTo(642);
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerCropResultMatchesTargetSizeWhileDesiredHeightIs0() {
  Request request = new Request.Builder(URI_1).resize(1080, 0).centerCrop().build();
  Bitmap source = Bitmap.createBitmap(640, 640, ARGB_8888);

  Bitmap result = transformResult(request, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  String scalePreOperation = shadowMatrix.getPreOperations().get(0);

  assertThat(scalePreOperation).startsWith("scale ");
  float scaleX = Float.valueOf(scalePreOperation.split(" ")[1]);
  float scaleY = Float.valueOf(scalePreOperation.split(" ")[2]);

  int transformedWidth = Math.round(result.getWidth() * scaleX);
  int transformedHeight = Math.round(result.getHeight() * scaleY);
  assertThat(transformedWidth).isEqualTo(1080);
  assertThat(transformedHeight).isEqualTo(1080);
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerInsideResultMatchesTargetSizeWhileDesiredWidthIs0() {
  Request request = new Request.Builder(URI_1).resize(0, 642).centerInside().build();
  Bitmap source = Bitmap.createBitmap(640, 640, ARGB_8888);

  Bitmap result = transformResult(request, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  String scalePreOperation = shadowMatrix.getPreOperations().get(0);

  assertThat(scalePreOperation).startsWith("scale ");
  float scaleX = Float.valueOf(scalePreOperation.split(" ")[1]);
  float scaleY = Float.valueOf(scalePreOperation.split(" ")[2]);

  int transformedWidth = Math.round(result.getWidth() * scaleX);
  int transformedHeight = Math.round(result.getHeight() * scaleY);
  assertThat(transformedWidth).isEqualTo(642);
  assertThat(transformedHeight).isEqualTo(642);
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerInsideResultMatchesTargetSizeWhileDesiredHeightIs0() {
  Request request = new Request.Builder(URI_1).resize(1080, 0).centerInside().build();
  Bitmap source = Bitmap.createBitmap(640, 640, ARGB_8888);

  Bitmap result = transformResult(request, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  String scalePreOperation = shadowMatrix.getPreOperations().get(0);

  assertThat(scalePreOperation).startsWith("scale ");
  float scaleX = Float.valueOf(scalePreOperation.split(" ")[1]);
  float scaleY = Float.valueOf(scalePreOperation.split(" ")[2]);

  int transformedWidth = Math.round(result.getWidth() * scaleX);
  int transformedHeight = Math.round(result.getHeight() * scaleY);
  assertThat(transformedWidth).isEqualTo(1080);
  assertThat(transformedHeight).isEqualTo(1080);
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerCropTallTooSmall() {
  Bitmap source = Bitmap.createBitmap(10, 20, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop().build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(5);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(10);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(10);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 4.0 4.0");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerCropTallTooLarge() {
  Bitmap source = Bitmap.createBitmap(100, 200, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(50, 50).centerCrop().build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(50);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(100);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(100);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 0.5 0.5");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerCropWideTooSmall() {
  Bitmap source = Bitmap.createBitmap(20, 10, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop().build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(5);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(10);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(10);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 4.0 4.0");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerCropWithGravityHorizontalLeft() {
  Bitmap source = Bitmap.createBitmap(20, 10, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop(Gravity.LEFT).build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(10);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(10);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 4.0 4.0");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerCropWithGravityHorizontalRight() {
  Bitmap source = Bitmap.createBitmap(20, 10, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop(Gravity.RIGHT).build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(10);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(10);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(10);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 4.0 4.0");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerCropWithGravityVerticalTop() {
  Bitmap source = Bitmap.createBitmap(10, 20, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop(Gravity.TOP).build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(10);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(10);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 4.0 4.0");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerCropWithGravityVerticalBottom() {
  Bitmap source = Bitmap.createBitmap(10, 20, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop(Gravity.BOTTOM).build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(10);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(10);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(10);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 4.0 4.0");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void centerCropWideTooLarge() {
  Bitmap source = Bitmap.createBitmap(200, 100, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(50, 50).centerCrop().build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(50);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(100);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(100);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 0.5 0.5");
}
项目:picasso    文件:BitmapHunterTest.java   
@Test public void centerCropTallTooSmall() throws Exception {
  Bitmap source = Bitmap.createBitmap(10, 20, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop().build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(5);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(10);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(10);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsOnly("scale 4.0 4.0");
}
项目:picasso    文件:BitmapHunterTest.java   
@Test public void centerCropTallTooLarge() throws Exception {
  Bitmap source = Bitmap.createBitmap(100, 200, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(50, 50).centerCrop().build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(50);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(100);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(100);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsOnly("scale 0.5 0.5");
}
项目:picasso    文件:BitmapHunterTest.java   
@Test public void centerCropWideTooSmall() throws Exception {
  Bitmap source = Bitmap.createBitmap(20, 10, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop().build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(5);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(10);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(10);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsOnly("scale 4.0 4.0");
}
项目:picasso    文件:BitmapHunterTest.java   
@Test public void centerCropWideTooLarge() throws Exception {
  Bitmap source = Bitmap.createBitmap(200, 100, ARGB_8888);
  Request data = new Request.Builder(URI_1).resize(50, 50).centerCrop().build();

  Bitmap result = transformResult(data, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
  assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(50);
  assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(0);
  assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(100);
  assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(100);

  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsOnly("scale 0.5 0.5");
}
项目:GitHub    文件:TransformationUtilsTest.java   
@Implementation
public static Bitmap createBitmap(int width, int height, Bitmap.Config config) {
  // Robolectric doesn't match the framework behavior with null configs, so we have to do so
  // here.
  Preconditions.checkNotNull("Config must not be null");
  return ShadowBitmap.createBitmap(width, height, config);
}
项目:GitHub    文件:AttributeStrategyTest.java   
@Test
public void testICanAddAndGetABitmapOfTheSameSizeAndDimensions() {
  Bitmap bitmap = ShadowBitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  strategy.put(bitmap);
  assertEquals(bitmap,
      strategy.get(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888));
}
项目:GitHub    文件:AttributeStrategyTest.java   
@Test
public void testMultipleBitmapsOfDifferentAttributesCanBeAddedAtOnce() {
  Bitmap first = ShadowBitmap.createBitmap(100, 100, Bitmap.Config.RGB_565);
  Bitmap second = ShadowBitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  Bitmap third = ShadowBitmap.createBitmap(120, 120, Bitmap.Config.RGB_565);

  strategy.put(first);
  strategy.put(second);
  strategy.put(third);

  assertEquals(first, strategy.get(100, 100, Bitmap.Config.RGB_565));
  assertEquals(second, strategy.get(100, 100, Bitmap.Config.ARGB_8888));
  assertEquals(third, strategy.get(120, 120, Bitmap.Config.RGB_565));
}
项目:GitHub    文件:TransformationUtilsTest.java   
@Implementation
public static Bitmap createBitmap(int width, int height, Bitmap.Config config) {
  // Robolectric doesn't match the framework behavior with null configs, so we have to do so
  // here.
  Preconditions.checkNotNull("Config must not be null");
  return ShadowBitmap.createBitmap(width, height, config);
}
项目:GitHub    文件:AttributeStrategyTest.java   
@Test
public void testICanAddAndGetABitmapOfTheSameSizeAndDimensions() {
  Bitmap bitmap = ShadowBitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  strategy.put(bitmap);
  assertEquals(bitmap,
      strategy.get(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888));
}
项目:GitHub    文件:AttributeStrategyTest.java   
@Test
public void testMultipleBitmapsOfDifferentAttributesCanBeAddedAtOnce() {
  Bitmap first = ShadowBitmap.createBitmap(100, 100, Bitmap.Config.RGB_565);
  Bitmap second = ShadowBitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  Bitmap third = ShadowBitmap.createBitmap(120, 120, Bitmap.Config.RGB_565);

  strategy.put(first);
  strategy.put(second);
  strategy.put(third);

  assertEquals(first, strategy.get(100, 100, Bitmap.Config.RGB_565));
  assertEquals(second, strategy.get(100, 100, Bitmap.Config.ARGB_8888));
  assertEquals(third, strategy.get(120, 120, Bitmap.Config.RGB_565));
}
项目:GitHub    文件:BitmapHunterTest.java   
@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");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void exifRotationSizing() throws Exception {
  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");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void exifRotationNoSizing() throws Exception {
  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");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void rotation90Sizing() throws Exception {
  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");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void rotation180Sizing() throws Exception {
  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");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void rotation90WithPivotSizing() throws Exception {
  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");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void exifVerticalFlip() {
  Request data = new Request.Builder(URI_1).rotate(-45).build();
  Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
  Bitmap result = transformResult(data, source, ORIENTATION_FLIP_VERTICAL);
  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 180.0");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void exifHorizontalFlip() {
  Request data = new Request.Builder(URI_1).rotate(-45).build();
  Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
  Bitmap result = transformResult(data, source, ORIENTATION_FLIP_HORIZONTAL);
  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()).doesNotContain("rotate 180.0");
  assertThat(shadowMatrix.getPreOperations()).doesNotContain("rotate 90.0");
  assertThat(shadowMatrix.getPreOperations()).doesNotContain("rotate 270.0");
}
项目:GitHub    文件:BitmapHunterTest.java   
@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");
}
项目:GitHub    文件:BitmapHunterTest.java   
@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");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void keepsAspectRationWhileResizingWhenDesiredWidthIs0() {
  Request request = new Request.Builder(URI_1).resize(20, 0).build();
  Bitmap source = Bitmap.createBitmap(40, 20, ARGB_8888);

  Bitmap result = transformResult(request, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 0.5 0.5");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void keepsAspectRationWhileResizingWhenDesiredHeightIs0() {
  Request request = new Request.Builder(URI_1).resize(0, 10).build();
  Bitmap source = Bitmap.createBitmap(40, 20, ARGB_8888);

  Bitmap result = transformResult(request, source, 0);

  ShadowBitmap shadowBitmap = shadowOf(result);
  Matrix matrix = shadowBitmap.getCreatedFromMatrix();
  ShadowMatrix shadowMatrix = shadowOf(matrix);
  assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 0.5 0.5");
}
项目:GitHub    文件:BitmapHunterTest.java   
@Test public void exifRotationWithManualRotation() {
  Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
  Request data = new Request.Builder(URI_1).rotate(-45).build();

  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");
  assertThat(shadowMatrix.getSetOperations()).containsEntry("rotate", "-45.0");
}
项目:GitHub    文件:BitmapHunterTest.java   
@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");
}
项目:GitHub    文件:BitmapHunterTest.java   
@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");
}