Java Code Examples for com.facebook.imagepipeline.request.ImageRequest#getImageDecodeOptions()

The following examples show how to use com.facebook.imagepipeline.request.ImageRequest#getImageDecodeOptions() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImagePipelineUtilsImplTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testBuildImageRequest_whenRoundAsCircle_thenApplyRoundingParameters() {
  when(mFrescoExperiments.useNativeRounding()).thenReturn(true);

  final ImageOptions imageOptions =
      ImageOptions.create().round(RoundingOptions.asCircle()).build();

  ImageRequest imageRequest = mImagePipelineUtils.buildImageRequest(URI, imageOptions);

  assertThat(imageRequest).isNotNull();
  assertThat(imageRequest.getSourceUri()).isEqualTo(URI);
  ImageDecodeOptions imageDecodeOptions = imageRequest.getImageDecodeOptions();
  assertThat(imageDecodeOptions).isNotEqualTo(ImageDecodeOptions.defaults());
  assertThat(imageDecodeOptions.bitmapTransformation)
      .isInstanceOf(CircularBitmapTransformation.class);

  CircularBitmapTransformation transformation =
      (CircularBitmapTransformation) imageDecodeOptions.bitmapTransformation;
  assertThat(transformation).isNotNull();
  assertThat(transformation.isAntiAliased()).isFalse();
}
 
Example 2
Source File: ImagePipelineUtilsImplTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void
    testBuildImageRequest_whenRoundAsCircleWithAntiAliasing_thenApplyRoundingParameters() {
  when(mFrescoExperiments.useNativeRounding()).thenReturn(true);

  final ImageOptions imageOptions =
      ImageOptions.create().round(RoundingOptions.asCircle(true)).build();

  ImageRequest imageRequest = mImagePipelineUtils.buildImageRequest(URI, imageOptions);

  assertThat(imageRequest).isNotNull();
  assertThat(imageRequest.getSourceUri()).isEqualTo(URI);
  ImageDecodeOptions imageDecodeOptions = imageRequest.getImageDecodeOptions();
  assertThat(imageDecodeOptions).isNotEqualTo(ImageDecodeOptions.defaults());
  assertThat(imageDecodeOptions.bitmapTransformation)
      .isInstanceOf(CircularBitmapTransformation.class);

  CircularBitmapTransformation transformation =
      (CircularBitmapTransformation) imageDecodeOptions.bitmapTransformation;
  assertThat(transformation).isNotNull();
  assertThat(transformation.isAntiAliased()).isTrue();
}
 
Example 3
Source File: DefaultCacheKeyFactory.java    From fresco with MIT License 6 votes vote down vote up
@Override
public CacheKey getPostprocessedBitmapCacheKey(
    ImageRequest request, @Nullable Object callerContext) {
  final Postprocessor postprocessor = request.getPostprocessor();
  final CacheKey postprocessorCacheKey;
  final String postprocessorName;
  if (postprocessor != null) {
    postprocessorCacheKey = postprocessor.getPostprocessorCacheKey();
    postprocessorName = postprocessor.getClass().getName();
  } else {
    postprocessorCacheKey = null;
    postprocessorName = null;
  }
  return new BitmapMemoryCacheKey(
      getCacheKeySourceUri(request.getSourceUri()).toString(),
      request.getResizeOptions(),
      request.getRotationOptions(),
      request.getImageDecodeOptions(),
      postprocessorCacheKey,
      postprocessorName,
      callerContext);
}
 
Example 4
Source File: DefaultCacheKeyFactory.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BitmapMemoryCacheKey getBitmapCacheKey(ImageRequest request) {
  return new BitmapMemoryCacheKey(
      getCacheKeySourceUri(request.getSourceUri()).toString(),
      request.getResizeOptions(),
      request.getAutoRotateEnabled(),
      request.getImageDecodeOptions());
}
 
Example 5
Source File: DefaultCacheKeyFactory.java    From fresco with MIT License 5 votes vote down vote up
@Override
public CacheKey getBitmapCacheKey(ImageRequest request, @Nullable Object callerContext) {
  return new BitmapMemoryCacheKey(
      getCacheKeySourceUri(request.getSourceUri()).toString(),
      request.getResizeOptions(),
      request.getRotationOptions(),
      request.getImageDecodeOptions(),
      null,
      null,
      callerContext);
}