Search in sources :

Example 1 with BlurPostprocessor

use of jp.wasabeef.fresco.processors.BlurPostprocessor 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());
    }
    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)

Example 2 with BlurPostprocessor

use of jp.wasabeef.fresco.processors.BlurPostprocessor 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

PipelineDraweeControllerBuilder (com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)2 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)2 ImageRequestBuilder (com.facebook.imagepipeline.request.ImageRequestBuilder)2 BlurPostprocessor (jp.wasabeef.fresco.processors.BlurPostprocessor)2 CombinePostProcessors (jp.wasabeef.fresco.processors.CombinePostProcessors)2 GrayscalePostprocessor (jp.wasabeef.fresco.processors.GrayscalePostprocessor)2