本文整理汇总了Java中com.facebook.imagepipeline.request.BasePostprocessor类的典型用法代码示例。如果您正苦于以下问题:Java BasePostprocessor类的具体用法?Java BasePostprocessor怎么用?Java BasePostprocessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasePostprocessor类属于com.facebook.imagepipeline.request包,在下文中一共展示了BasePostprocessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
public static void load(Uri uri,SimpleDraweeView draweeView,BasePostprocessor processor,int width,int height,
BaseControllerListener listener){
ImageRequest request =
ImageRequestBuilder.newBuilderWithSource(uri)
.setPostprocessor(processor)
.setResizeOptions(new ResizeOptions(width,height))
//缩放,在解码前修改内存中的图片大小, 配合Downsampling可以处理所有图片,否则只能处理jpg,
// 开启Downsampling:在初始化时设置.setDownsampleEnabled(true)
.setProgressiveRenderingEnabled(true)//支持图片渐进式加载
.setAutoRotateEnabled(true) //如果图片是侧着,可以自动旋转
.build();
PipelineDraweeController controller =
(PipelineDraweeController) Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setControllerListener(listener)
.setOldController(draweeView.getController())
.setAutoPlayAnimations(true) //自动播放gif动画
.build();
draweeView.setController(controller);
}
示例2: getImageController
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
private DraweeController getImageController(String imagePath, DraweeController oldController) {
String address = "http://image.tmdb.org/t/p/w" + "300" + imagePath;
Log.d("FRESCOLOADING", address);
Uri uri = Uri.parse(address);
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
.setProgressiveRenderingEnabled(true)
.setPostprocessor(new BasePostprocessor() {
@Override
public void process(Bitmap bitmap) {
super.process(bitmap);
Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
int primaryDark = ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark);
int primary = ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary);
mBinding.collapsingToolbar.setContentScrimColor(palette.getMutedColor(primary));
mBinding.collapsingToolbar.setStatusBarScrimColor(palette.getDarkVibrantColor(primaryDark));
}
});
}
})
.build();
return Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(oldController)
.build();
}
示例3: convert
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
@Override
public void convert(final BaseViewHolder holder, final TngouModel.TngouBean tngouBean, final int position) {
super.convert(holder, tngouBean, position);
final SimpleDraweeView mImage = holder.getView(R.id.mImage);
final String url = RequestServiceTngou.ImageHear + tngouBean.img;
Uri uri = Uri.parse(url);
Postprocessor redMeshPostprocessor = new BasePostprocessor() {
@Override
public String getName() {
return url;
}
@Override
public void process(Bitmap bitmap) {
if (imageHeights.get(url + "height") == null) {
imageHeights.put(url + "height", UtilsDynamicSize.defaultDisplayWidth / 3 * bitmap.getHeight() / bitmap.getWidth());
imageHeights.put(url + "width", UtilsDynamicSize.defaultDisplayWidth / 3);
}
mImage.getLayoutParams().height = imageHeights.get(url + "height");
mImage.getLayoutParams().width = imageHeights.get(url + "width");
}
};
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
.setPostprocessor(redMeshPostprocessor)
.build();
PipelineDraweeController controller = (PipelineDraweeController)
Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(mImage.getController())
// other setters as you need
.build();
mImage.setController(controller);
}
示例4: convert
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
@Override
public void convert(final BaseViewHolder holder, final MzituModel bean, final int position) {
super.convert(holder, bean, position);
final SimpleDraweeView mImage = holder.getView(R.id.mImage);
final String url = bean.imagePath;
Uri uri = Uri.parse(url);
Postprocessor redMeshPostprocessor = new BasePostprocessor() {
@Override
public String getName() {
return url;
}
@Override
public void process(Bitmap bitmap) {
if (imageHeights.get(url + "height") == null) {
imageHeights.put(url + "height", UtilsDynamicSize.defaultDisplayWidth / 3 * bitmap.getHeight() / bitmap.getWidth());
imageHeights.put(url + "width", UtilsDynamicSize.defaultDisplayWidth / 3);
}
mImage.getLayoutParams().height = imageHeights.get(url + "height");
mImage.getLayoutParams().width = imageHeights.get(url + "width");
}
};
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
.setPostprocessor(redMeshPostprocessor)
.build();
PipelineDraweeController controller = (PipelineDraweeController)
Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(mImage.getController())
// other setters as you need
.build();
mImage.setController(controller);
}
示例5: LoadImageFromURLAndCallBack
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
public static void LoadImageFromURLAndCallBack(SimpleDraweeView destImageView , String URL, Context context, BaseBitmapDataSubscriber bbds
, BasePostprocessor postprocessor)
{
int w = destImageView.getWidth();
int h =destImageView.getHeight();
if(w<1){
w = destImageView.getLayoutParams().width;
}
if(h<1){
h =destImageView.getLayoutParams().height;
}
ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(URL))
.setResizeOptions(new ResizeOptions(w,h))
.setProgressiveRenderingEnabled(true);
if(postprocessor!=null){
builder.setPostprocessor(postprocessor);
}
ImageRequest imageRequest =
builder
.build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
dataSource.subscribe(bbds, CallerThreadExecutor.getInstance());
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
.setImageRequest(imageRequest)
.setOldController(destImageView.getController())
.setAutoPlayAnimations(true)
.build();
destImageView.setController(draweeController);
}
示例6: process
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
@Override
public void process(Bitmap dest, Bitmap src) {
Canvas canvas = new Canvas(dest);
Paint paint = new Paint();
canvas.drawBitmap(src, 0, 0, paint);
for(BasePostprocessor processor : mProcessors) {
processor.process(dest, dest);
}
}
示例7: BenchmarkPostprocessorForDuplicatedBitmap
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
public BenchmarkPostprocessorForDuplicatedBitmap(
DurationCallback durationCallback, BasePostprocessor postprocessor) {
super(durationCallback);
mPostprocessor = postprocessor;
}
示例8: BenchmarkPostprocessorForManualBitmapHandling
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
public BenchmarkPostprocessorForManualBitmapHandling(
DurationCallback durationCallback, BasePostprocessor postprocessor) {
super(durationCallback);
mPostprocessor = postprocessor;
}
示例9: BenchmarkPostprocessorForDuplicatedBitmapInPlace
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
public BenchmarkPostprocessorForDuplicatedBitmapInPlace(
DurationCallback durationCallback, BasePostprocessor postprocessor) {
super(durationCallback);
mPostprocessor = postprocessor;
}
示例10: getBitmapWithQiniu
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
public static void getBitmapWithQiniu(@NonNull final String url, @NonNull final int width, @NonNull final int height,
@Nullable BasePostprocessor processor, @NonNull final FrescoUtil.BitmapListener listener){
String newUrl = QiniuUtils.getSamllImage(url,width,height,QiniuUtils.isWWW,true);
FrescoUtil.getBitmapWithProcessor(newUrl,context,width,height,processor,listener);
}
示例11: getBitmap
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
public static void getBitmap(@NonNull final String url, @NonNull final int width, @NonNull final int height,
@Nullable BasePostprocessor processor, @NonNull final FrescoUtil.BitmapListener listener){
FrescoUtil.getBitmapWithProcessor(url,context,width,height,processor,listener);
}
示例12: setImageURI
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
@Override public void setImageURI(Uri uri, Object callerContext) {
// http://frescolib.org/docs/modifying-image.html
// this post process will do two things: 1. resize if image width is too large; 2. split if image height is too large
Postprocessor postProcessor = new BasePostprocessor() {
@Override public String getName() {
return "SplitLongImagePostProcessor";
}
@Override public CloseableReference<Bitmap> process(Bitmap sourceBitmap, PlatformBitmapFactory bitmapFactory) {
CloseableReference<Bitmap> bitmapRef = null;
try {
// resize image if its width is too large: > windowWidth * 1.5
double ratio = 1.0;
if (sourceBitmap.getWidth() >= WindowWidth * 1.5) {
ratio = (double) WindowWidth / sourceBitmap.getWidth();
}
bitmapRef = bitmapFactory.createBitmap((int) (sourceBitmap.getWidth() * ratio), (int) (sourceBitmap.getHeight() * ratio));
Bitmap destBitmap = bitmapRef.get();
Canvas canvas = new Canvas(destBitmap);
Rect destRect = new Rect(0, 0, destBitmap.getWidth(), destBitmap.getHeight());
canvas.drawBitmap(sourceBitmap, null, destRect, paint);
// split images if its height is too large: > OpenGL max Height
try {
int imageTotalHeight = destBitmap.getHeight();
double imageAspectRatio = destBitmap.getWidth() / (double) WindowWidth;
int imageMaxAllowedHeight;
if (imageAspectRatio < 1) {
imageMaxAllowedHeight = (int) (ImageUtils.getMaxHeight() * imageAspectRatio) - 5;
} else {
imageMaxAllowedHeight = ImageUtils.getMaxHeight() - 5;
}
int imageCount = getTimes(imageTotalHeight, imageMaxAllowedHeight);
// Log.d(TAG, "process: h = " + imageTotalHeight + " w = " + destBitmap.getWidth() + " allowed: " + imageMaxAllowedHeight + " count: " + imageCount);
if (imageCount > 1) {
bmps = new ArrayList<Bitmap>();
Rect bsrc = new Rect();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
destBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
InputStream isBm = new ByteArrayInputStream(baos.toByteArray());
BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(isBm, true);
for (int i = 0; i < imageCount; i++) {
bsrc.left = 0;
bsrc.top = i * imageMaxAllowedHeight;
bsrc.right = destBitmap.getWidth();
bsrc.bottom = Math.min(bsrc.top + imageMaxAllowedHeight, imageTotalHeight);
Bitmap bmp = decoder.decodeRegion(bsrc, null);
bmps.add(bmp);
}
}
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
return CloseableReference.cloneOrNull(bitmapRef);
} finally {
CloseableReference.closeSafely(bitmapRef);
}
}
};
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setAutoRotateEnabled(true)
// this will reduce image's size if it's wider than screen width
// .setResizeOptions(new ResizeOptions(WindowWidth, Integer.MAX_VALUE))
.setPostprocessor(postProcessor).build();
DraweeController controller = ((PipelineDraweeControllerBuilder) getControllerBuilder()).setImageRequest(request)
.setControllerListener(listener)
.setCallerContext(callerContext)
.setAutoPlayAnimations(true)
.setOldController(getController())
.build();
setController(controller);
}
示例13: CombinePostProcessors
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
private CombinePostProcessors(List<BasePostprocessor> processors) {
super();
mProcessors = processors;
}
示例14: Builder
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
public Builder() {
processors = new ArrayList<BasePostprocessor>();
}
示例15: add
import com.facebook.imagepipeline.request.BasePostprocessor; //导入依赖的package包/类
public Builder add(BasePostprocessor processor) {
processors.add(processor);
return this;
}