Search in sources :

Example 56 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project fresco by facebook.

the class ImageRequestTest method testCreatingRequestFromExistingRequest.

@Test
public void testCreatingRequestFromExistingRequest() {
    ImageRequest original = ImageRequestBuilder.newBuilderWithSource(Uri.parse("http://frescolib.org/image.jpg")).setCacheChoice(ImageRequest.CacheChoice.SMALL).setImageDecodeOptions(new ImageDecodeOptionsBuilder().build()).setLocalThumbnailPreviewsEnabled(true).setLowestPermittedRequestLevel(ImageRequest.RequestLevel.DISK_CACHE).setPostprocessor(new BasePostprocessor() {

        @Override
        public String getName() {
            return super.getName();
        }
    }).setProgressiveRenderingEnabled(true).setRequestListener(new RequestLoggingListener()).setResizeOptions(new ResizeOptions(20, 20)).setRotationOptions(RotationOptions.forceRotation(RotationOptions.ROTATE_90)).setRequestPriority(Priority.HIGH).build();
    ImageRequest copy = ImageRequestBuilder.fromRequest(original).build();
    assertThat(copy).isEqualTo(original);
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) RequestLoggingListener(com.facebook.imagepipeline.listener.RequestLoggingListener) ImageDecodeOptionsBuilder(com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder) Test(org.junit.Test)

Example 57 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project fresco by facebook.

the class VitoViewRecyclerFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    final RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
    recyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            final int imageSize = (right - left) / SPAN_COUNT;
            mResizeOptions = new ResizeOptions(imageSize, imageSize);
            mOptionsBuilder = mOptionsBuilder.resize(mResizeOptions);
        }
    });
    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), SPAN_COUNT);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setHasFixedSize(true);
    final SimpleAdapter adapter = new SimpleAdapter(new ArrayList<Uri>());
    recyclerView.setAdapter(adapter);
    final Spinner imageSource = view.findViewById(R.id.spinner_image_source);
    ImageSourceSpinner.INSTANCE.setup(imageSource, sampleUris(), new Function1<List<Uri>, Unit>() {

        @Override
        public Unit invoke(List<Uri> uris) {
            adapter.setData(uris);
            return null;
        }
    });
}
Also used : ImageSourceSpinner(com.facebook.fresco.samples.showcase.misc.ImageSourceSpinner) Spinner(android.widget.Spinner) Unit(kotlin.Unit) VitoView(com.facebook.fresco.vito.view.VitoView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Uri(android.net.Uri) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) RecyclerView(androidx.recyclerview.widget.RecyclerView) ArrayList(java.util.ArrayList) List(java.util.List)

Example 58 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project teaTime by ancfdy.

the class FrescoUtils method loadImage.

/**
 * 请求图片
 * @param uri - 唯一的必选的成员. 参考 支持的URIs
 * @param width
 * @param height
 * autoRotateEnabled - 是否支持自动旋转.
 * progressiveEnabled - 是否支持渐进式加载.
 * postprocessor - 后处理器(postprocess).
 * resizeOptions - 图片缩放选项,用前请先阅读缩放和旋转
 */
public static void loadImage(SimpleDraweeView draweeView, String uri, int width, int height) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri)).setAutoRotateEnabled(// 是否支持自动旋转.
    true).setImageDecodeOptions(// 图片解码库
    getImageDecodeOptions()).setLowestPermittedRequestLevel(// 请求经过缓存级别  BITMAP_MEMORY_CACHE,ENCODED_MEMORY_CACHE,DISK_CACHE,FULL_FETCH
    RequestLevel.FULL_FETCH).setProgressiveRenderingEnabled(// 渐进加载,主要用于渐进式的JPEG图,影响图片显示速度(普通)
    false).setResizeOptions(new ResizeOptions(width, height)).build();
    DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).setOldController(draweeView.getController()).build();
    draweeView.setController(controller);
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest)

Example 59 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project MyDiary by erttyy8821.

the class DiaryPhotoLayout method setPhotoUri.

public void setPhotoUri(Uri photoUri) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(photoUri).setResizeOptions(new ResizeOptions(DiaryItemHelper.getVisibleWidth(getContext()), DiaryItemHelper.getVisibleHeight(getContext()))).setRotationOptions(RotationOptions.autoRotate()).build();
    DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).build();
    SDV_diary_new_photo.setController(controller);
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest)

Example 60 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project MyDiary by erttyy8821.

the class PhotoOverviewAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final SimpleViewHolder holder, final int position) {
    final Uri photoUri = diaryPhotoFileList.get(position);
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(diaryPhotoFileList.get(position)).setResizeOptions(new ResizeOptions(resizePhotoWidth, resizePhotoHeight)).build();
    DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).setTapToRetryEnabled(false).build();
    holder.SDV_CV_diary_photo_overview.setController(controller);
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Uri(android.net.Uri)

Aggregations

ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)63 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)31 Uri (android.net.Uri)12 Test (org.junit.Test)11 DraweeController (com.facebook.drawee.interfaces.DraweeController)10 PipelineDraweeController (com.facebook.drawee.backends.pipeline.PipelineDraweeController)9 ImageRequestBuilder (com.facebook.imagepipeline.request.ImageRequestBuilder)7 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)6 File (java.io.File)5 PipelineDraweeControllerBuilder (com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 Drawable (android.graphics.drawable.Drawable)3 CloseableReference (com.facebook.common.references.CloseableReference)3 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)3 FileSystemReference (im.actor.runtime.files.FileSystemReference)3 Context (android.content.Context)2 Canvas (android.graphics.Canvas)2 Point (android.graphics.Point)2 Animatable (android.graphics.drawable.Animatable)2 View (android.view.View)2