当前位置: 首页>>代码示例>>Java>>正文


Java ShadowBitmap类代码示例

本文整理汇总了Java中org.robolectric.shadows.ShadowBitmap的典型用法代码示例。如果您正苦于以下问题:Java ShadowBitmap类的具体用法?Java ShadowBitmap怎么用?Java ShadowBitmap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ShadowBitmap类属于org.robolectric.shadows包,在下文中一共展示了ShadowBitmap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLeastRecentlyUsedAttributeSetIsRemovedFirst

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:AttributeStrategyTest.java

示例2: centerCropResultMatchesTargetSize

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:BitmapHunterTest.java

示例3: centerCropResultMatchesTargetSizeWhileDesiredWidthIs0

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:BitmapHunterTest.java

示例4: centerCropResultMatchesTargetSizeWhileDesiredHeightIs0

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:BitmapHunterTest.java

示例5: centerInsideResultMatchesTargetSizeWhileDesiredWidthIs0

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:BitmapHunterTest.java

示例6: centerInsideResultMatchesTargetSizeWhileDesiredHeightIs0

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:BitmapHunterTest.java

示例7: centerCropTallTooSmall

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BitmapHunterTest.java

示例8: centerCropTallTooLarge

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BitmapHunterTest.java

示例9: centerCropWideTooSmall

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BitmapHunterTest.java

示例10: centerCropWithGravityHorizontalLeft

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BitmapHunterTest.java

示例11: centerCropWithGravityHorizontalRight

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BitmapHunterTest.java

示例12: centerCropWithGravityVerticalTop

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BitmapHunterTest.java

示例13: centerCropWithGravityVerticalBottom

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BitmapHunterTest.java

示例14: centerCropWideTooLarge

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BitmapHunterTest.java

示例15: centerCropTallTooSmall

import org.robolectric.shadows.ShadowBitmap; //导入依赖的package包/类
@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");
}
 
开发者ID:Pixate,项目名称:picasso,代码行数:18,代码来源:BitmapHunterTest.java


注:本文中的org.robolectric.shadows.ShadowBitmap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。