Java 类com.facebook.imagepipeline.request.BasePostprocessor 实例源码

项目:fastDev    文件:FrescoUtils.java   
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);
}
项目:Blockbuster    文件:MovieDetailsActivity.java   
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();
}
项目:WhiteRead    文件:TngouFragment.java   
@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);
}
项目:WhiteRead    文件:MzituFragment.java   
@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);
}
项目:nono-android    文件:FrescoImageloadHelper.java   
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);
}
项目:Blockbuster    文件:MovieDetailsActivity.java   
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();
}
项目:fresco-processors    文件:CombinePostProcessors.java   
@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);
    }
}
项目:GitHub    文件:BenchmarkPostprocessorForDuplicatedBitmap.java   
public BenchmarkPostprocessorForDuplicatedBitmap(
    DurationCallback durationCallback, BasePostprocessor postprocessor) {
  super(durationCallback);
  mPostprocessor = postprocessor;
}
项目:GitHub    文件:BenchmarkPostprocessorForManualBitmapHandling.java   
public BenchmarkPostprocessorForManualBitmapHandling(
    DurationCallback durationCallback, BasePostprocessor postprocessor) {
  super(durationCallback);
  mPostprocessor = postprocessor;
}
项目:GitHub    文件:BenchmarkPostprocessorForDuplicatedBitmapInPlace.java   
public BenchmarkPostprocessorForDuplicatedBitmapInPlace(
    DurationCallback durationCallback, BasePostprocessor postprocessor) {
  super(durationCallback);
  mPostprocessor = postprocessor;
}
项目:MyImageUtil    文件:MyImageUtil.java   
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);
}
项目:MyImageUtil    文件:MyImageUtil.java   
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);
}
项目:zSMTH-Android    文件:WrapContentDraweeView.java   
@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);
}
项目:fresco-processors    文件:CombinePostProcessors.java   
private CombinePostProcessors(List<BasePostprocessor> processors) {
    super();
    mProcessors = processors;
}
项目:fresco-processors    文件:CombinePostProcessors.java   
public Builder() {
    processors = new ArrayList<BasePostprocessor>();
}
项目:fresco-processors    文件:CombinePostProcessors.java   
public Builder add(BasePostprocessor processor) {
    processors.add(processor);
    return this;
}
项目:fresco    文件:BenchmarkPostprocessorForDuplicatedBitmap.java   
public BenchmarkPostprocessorForDuplicatedBitmap(
    DurationCallback durationCallback, BasePostprocessor postprocessor) {
  super(durationCallback);
  mPostprocessor = postprocessor;
}
项目:fresco    文件:BenchmarkPostprocessorForManualBitmapHandling.java   
public BenchmarkPostprocessorForManualBitmapHandling(
    DurationCallback durationCallback, BasePostprocessor postprocessor) {
  super(durationCallback);
  mPostprocessor = postprocessor;
}
项目:fresco    文件:BenchmarkPostprocessorForDuplicatedBitmapInPlace.java   
public BenchmarkPostprocessorForDuplicatedBitmapInPlace(
    DurationCallback durationCallback, BasePostprocessor postprocessor) {
  super(durationCallback);
  mPostprocessor = postprocessor;
}
项目:MyImageUtil    文件:FrescoUtil.java   
/**
 *  If the image has some ResizeOptions we put also the resized image into the cache with different key.
 *  currently don't support downsampling / resizing for GIFs.
 * @param url
 * @param draweeView
 * @param processor
 * @param width
 * @param height
 * @param listener
 */
public static void loadUrl(String url, SimpleDraweeView draweeView, BasePostprocessor processor, int width, int height,
                           BaseControllerListener listener){

    url = append(url);
   load(Uri.parse(url),draweeView,processor,width,height,listener);

}
项目:ImageSliderByFresco    文件:FrescoUtil.java   
/**
 *  If the image has some ResizeOptions we put also the resized image into the cache with different key.
 *  currently don't support downsampling / resizing for GIFs.
 * @param url
 * @param draweeView
 * @param processor
 * @param width
 * @param height
 * @param listener
 */
public static void loadUrl(String url, SimpleDraweeView draweeView, BasePostprocessor processor, int width, int height,
                           BaseControllerListener listener){

    url = append(url);
   load(Uri.parse(url),draweeView,processor,width,height,listener);

}
项目:fastDev    文件:FrescoUtils.java   
public static void loadFile(String file, SimpleDraweeView draweeView,BasePostprocessor processor,int width,int height,
                            BaseControllerListener listener){

    load(getFileUri(file),draweeView,processor,width,height,listener);

}
项目:fastDev    文件:FrescoUtils.java   
public static void loadFile(File file, SimpleDraweeView draweeView,BasePostprocessor processor,int width,int height,
                            BaseControllerListener listener){

    load(getFileUri(file),draweeView,processor,width,height,listener);

}
项目:fastDev    文件:FrescoUtils.java   
public static void loadRes(int resId, SimpleDraweeView draweeView,BasePostprocessor processor,int width,int height,
                           BaseControllerListener listener){

    load(getResUri(resId),draweeView,processor,width,height,listener);

}
项目:MyImageUtil    文件:FrescoUtil.java   
public static void loadFile(String file, SimpleDraweeView draweeView, BasePostprocessor processor, int width, int height,
                            BaseControllerListener listener){

    load(getFileUri(file),draweeView,processor,width,height,listener);

}
项目:MyImageUtil    文件:FrescoUtil.java   
public static void loadFile(File file, SimpleDraweeView draweeView, BasePostprocessor processor, int width, int height,
                            BaseControllerListener listener){

    load(getFileUri(file),draweeView,processor,width,height,listener);

}
项目:MyImageUtil    文件:FrescoUtil.java   
public static void loadRes(int resId, SimpleDraweeView draweeView, BasePostprocessor processor, int width, int height,
                           BaseControllerListener listener){

    load(getResUri(resId),draweeView,processor,width,height,listener);

}
项目:FrescoUtlis    文件:FrescoUtils.java   
public static void loadFile(String file, SimpleDraweeView draweeView,BasePostprocessor processor,int width,int height,
                           BaseControllerListener listener){

    load(getFileUri(file),draweeView,processor,width,height,listener);

}
项目:FrescoUtlis    文件:FrescoUtils.java   
public static void loadFile(File file, SimpleDraweeView draweeView,BasePostprocessor processor,int width,int height,
                            BaseControllerListener listener){

    load(getFileUri(file),draweeView,processor,width,height,listener);

}
项目:FrescoUtlis    文件:FrescoUtils.java   
public static void loadRes(int resId, SimpleDraweeView draweeView,BasePostprocessor processor,int width,int height,
                            BaseControllerListener listener){

    load(getResUri(resId),draweeView,processor,width,height,listener);

}
项目:ImageSliderByFresco    文件:FrescoUtil.java   
public static void loadFile(String file, SimpleDraweeView draweeView, BasePostprocessor processor, int width, int height,
                            BaseControllerListener listener){

    load(getFileUri(file),draweeView,processor,width,height,listener);

}
项目:ImageSliderByFresco    文件:FrescoUtil.java   
public static void loadFile(File file, SimpleDraweeView draweeView, BasePostprocessor processor, int width, int height,
                            BaseControllerListener listener){

    load(getFileUri(file),draweeView,processor,width,height,listener);

}
项目:ImageSliderByFresco    文件:FrescoUtil.java   
public static void loadRes(int resId, SimpleDraweeView draweeView, BasePostprocessor processor, int width, int height,
                           BaseControllerListener listener){

    load(getResUri(resId),draweeView,processor,width,height,listener);

}
项目:fastDev    文件:FrescoUtils.java   
/**
 *  If the image has some ResizeOptions we put also the resized image into the cache with different key.
 *  currently don't support downsampling / resizing for GIFs.
 * @param url
 * @param draweeView
 * @param processor
 * @param width
 * @param height
 * @param listener
 */
public static void loadUrl(String url, SimpleDraweeView draweeView,BasePostprocessor processor,int width,int height,
                           BaseControllerListener listener){

    load(Uri.parse(url),draweeView,processor,width,height,listener);

}
项目:FrescoUtlis    文件:FrescoUtils.java   
/**
 *  If the image has some ResizeOptions we put also the resized image into the cache with different key.
 *  currently don't support downsampling / resizing for GIFs.
 * @param url
 * @param draweeView
 * @param processor
 * @param width
 * @param height
 * @param listener
 */
public static void loadUrl(String url, SimpleDraweeView draweeView,BasePostprocessor processor,int width,int height,
                           BaseControllerListener listener){

   load(Uri.parse(url),draweeView,processor,width,height,listener);

}