Search in sources :

Example 21 with ResizeOptions

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

the class LocalContentUriThumbnailFetchProducerTest method mockResizeOptions.

private void mockResizeOptions(int width, int height) {
    ResizeOptions resizeOptions = new ResizeOptions(width, height);
    when(mImageRequest.getResizeOptions()).thenReturn(resizeOptions);
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions)

Example 22 with ResizeOptions

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

the class FrescoUtils method changeImgSize.

/**
 * 自定义图片尺寸
 * @param draweeView 显示的控件
 * @param uriString 地址
 * @param width 50
 * @param height 50
 */
public static void changeImgSize(SimpleDraweeView draweeView, String uriString, int width, int height) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uriString)).setResizeOptions(new ResizeOptions(width, height)).build();
    DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).setAutoPlayAnimations(// other setters
    true).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 23 with ResizeOptions

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

the class FrescoUtils method changeImgSize.

/**
 * 自定义图片尺寸
 * @param draweeView 显示的控件
 * @param uriString 地址
 * @param width 50
 * @param height 50
 */
public static void changeImgSize(SimpleDraweeView draweeView, String uriString, int width, int height) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uriString)).setResizeOptions(new ResizeOptions(width, height)).build();
    DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).setAutoPlayAnimations(// other setters
    true).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 24 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 25 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project DevRing by LJYcoder.

the class FrescoManager method getImageRequest.

/**
 * 构建、获取ImageRequest
 *
 * @param uri              加载路径
 * @param simpleDraweeView 加载的图片控件
 * @param loadOption       临时加载选项
 * @return ImageRequest
 */
private ImageRequest getImageRequest(Uri uri, SimpleDraweeView simpleDraweeView, LoadOption loadOption) {
    int width;
    int height;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        width = simpleDraweeView.getWidth();
        height = simpleDraweeView.getHeight();
    } else {
        width = simpleDraweeView.getMaxWidth();
        height = simpleDraweeView.getMaxHeight();
    }
    // 根据加载路径生成ImageRequest的构造者
    ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(uri);
    // 调整解码图片的大小
    if (width > 0 && height > 0) {
        builder.setResizeOptions(new ResizeOptions(width, height));
    }
    // 是否开启渐进式加载,仅支持JPEG图片
    builder.setProgressiveRenderingEnabled(true);
    if (loadOption != null) {
        // 图片变换处理
        CombinePostProcessors.Builder processorBuilder = new CombinePostProcessors.Builder();
        if (loadOption.getBlurRadius() > 0) {
            processorBuilder.add(new BlurPostprocessor(mContext, loadOption.getBlurRadius()));
        }
        if (loadOption.isGray()) {
            processorBuilder.add(new GrayscalePostprocessor());
        }
        builder.setPostprocessor(processorBuilder.build());
        if (!loadOption.isUseMemoryCache()) {
        // Fresco貌似不支持禁用内存缓存?
        }
        if (!loadOption.isUseDiskCache()) {
            builder.disableDiskCache();
        }
    } else {
        if (!mImageConfig.isUseMemoryCache()) {
        // Fresco貌似不支持禁用内存缓存?
        }
        if (!mImageConfig.isUseDiskCache()) {
            builder.disableDiskCache();
        }
    }
    return builder.build();
}
Also used : BlurPostprocessor(jp.wasabeef.fresco.processors.BlurPostprocessor) GrayscalePostprocessor(jp.wasabeef.fresco.processors.GrayscalePostprocessor) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) PipelineDraweeControllerBuilder(com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder) ImageRequestBuilder(com.facebook.imagepipeline.request.ImageRequestBuilder) CombinePostProcessors(jp.wasabeef.fresco.processors.CombinePostProcessors) ImageRequestBuilder(com.facebook.imagepipeline.request.ImageRequestBuilder)

Aggregations

ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)59 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)27 Uri (android.net.Uri)12 Test (org.junit.Test)11 DraweeController (com.facebook.drawee.interfaces.DraweeController)10 ImageRequestBuilder (com.facebook.imagepipeline.request.ImageRequestBuilder)7 PipelineDraweeController (com.facebook.drawee.backends.pipeline.PipelineDraweeController)5 File (java.io.File)5 PipelineDraweeControllerBuilder (com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)4 Drawable (android.graphics.drawable.Drawable)3 CloseableReference (com.facebook.common.references.CloseableReference)3 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)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 Spinner (android.widget.Spinner)2