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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations