Search in sources :

Example 81 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.

the class ImagePipelineUtilsImplTest method testBuildImageRequest_whenUriNotNull_thenReturnRequest.

@Test
public void testBuildImageRequest_whenUriNotNull_thenReturnRequest() {
    ImageRequest imageRequest = mImagePipelineUtils.buildImageRequest(URI, ImageOptions.defaults());
    assertThat(imageRequest).isNotNull();
    assertThat(imageRequest.getSourceUri()).isEqualTo(URI);
}
Also used : ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Test(org.junit.Test)

Example 82 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.

the class ImagePipelineUtilsImplTest method testBuildImageRequest_whenRotatingEnabled_thenSetRotateOptions.

@Test
public void testBuildImageRequest_whenRotatingEnabled_thenSetRotateOptions() {
    RotationOptions rotationOptions = RotationOptions.forceRotation(RotationOptions.ROTATE_270);
    final ImageOptions imageOptions = ImageOptions.create().rotate(rotationOptions).build();
    ImageRequest imageRequest = mImagePipelineUtils.buildImageRequest(URI, imageOptions);
    assertThat(imageRequest).isNotNull();
    assertThat(imageRequest.getSourceUri()).isEqualTo(URI);
    assertThat(imageRequest.getRotationOptions()).isEqualTo(rotationOptions);
}
Also used : ImageRequest(com.facebook.imagepipeline.request.ImageRequest) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) RotationOptions(com.facebook.imagepipeline.common.RotationOptions) Test(org.junit.Test)

Example 83 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.

the class VitoImagePipelineImpl method createImageRequest.

@Override
public VitoImageRequest createImageRequest(Resources resources, ImageSource imageSource, @Nullable ImageOptions options) {
    if (options == null) {
        options = ImageOptions.defaults();
    }
    if (!(imageSource instanceof VitoImageSource)) {
        throw new IllegalArgumentException("ImageSource not supported: " + imageSource);
    }
    VitoImageSource vitoImageSource = (VitoImageSource) imageSource;
    CacheKey finalImageCacheKey = null;
    ImageRequest finalImageRequest = vitoImageSource.maybeExtractFinalImageRequest(mImagePipelineUtils, options);
    if (finalImageRequest != null) {
        finalImageCacheKey = mImagePipeline.getCacheKey(finalImageRequest, null);
    }
    return new VitoImageRequest(resources, imageSource, options, finalImageRequest, finalImageCacheKey);
}
Also used : VitoImageRequest(com.facebook.fresco.vito.core.VitoImageRequest) VitoImageRequest(com.facebook.fresco.vito.core.VitoImageRequest) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) VitoImageSource(com.facebook.fresco.vito.core.impl.source.VitoImageSource) CacheKey(com.facebook.cache.common.CacheKey)

Example 84 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project gl-react-native by ProjectSeptemberInc.

the class GLImage method reloadImage.

private void reloadImage() {
    if (pending != null && !pending.isFinished())
        pending.close();
    final Uri uri = src;
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri).setAutoRotateEnabled(// I don't really understand why need to disable this. but it actually fixes the image is properly rotated according to EXIF data
    false).build();
    pending = Fresco.getImagePipeline().fetchDecodedImage(imageRequest, null);
    pending.subscribe(new BaseBitmapDataSubscriber() {

        @Override
        protected void onNewResultImpl(@Nullable Bitmap bitmap) {
            onLoad(bitmap);
        }

        @Override
        protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
            Log.e("GLImage", "Failed to load '" + uri.getPath() + "'", dataSource.getFailureCause());
        }
    }, decodeExecutor);
}
Also used : Bitmap(android.graphics.Bitmap) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) CloseableReference(com.facebook.common.references.CloseableReference) Uri(android.net.Uri) BaseBitmapDataSubscriber(com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber)

Example 85 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project teaTime by ancfdy.

the class FrescoUtils method loadGif.

/**
 * 加载gif图
 * @param draweeView
 * @param uriString
 */
public static void loadGif(SimpleDraweeView draweeView, String uriString) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uriString)).build();
    DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).setAutoPlayAnimations(true).build();
    draweeView.setController(controller);
}
Also used : DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest)

Aggregations

ImageRequest (com.facebook.imagepipeline.request.ImageRequest)100 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)26 DraweeController (com.facebook.drawee.interfaces.DraweeController)25 CloseableReference (com.facebook.common.references.CloseableReference)24 Uri (android.net.Uri)18 ImagePipeline (com.facebook.imagepipeline.core.ImagePipeline)17 Test (org.junit.Test)14 Bitmap (android.graphics.Bitmap)13 CacheKey (com.facebook.cache.common.CacheKey)12 File (java.io.File)11 DataSource (com.facebook.datasource.DataSource)10 BaseBitmapDataSubscriber (com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber)9 CloseableImage (com.facebook.imagepipeline.image.CloseableImage)8 ImageRequestBuilder (com.facebook.imagepipeline.request.ImageRequestBuilder)8 Animatable (android.graphics.drawable.Animatable)7 PipelineDraweeController (com.facebook.drawee.backends.pipeline.PipelineDraweeController)7 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)7 ImageOptions (com.facebook.fresco.vito.options.ImageOptions)7 ImageInfo (com.facebook.imagepipeline.image.ImageInfo)7 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)6