fresco icon indicating copy to clipboard operation
fresco copied to clipboard

How to load image when using postprocessor

Open andrijans opened this issue 11 years ago • 2 comments

How to load image into drawee when use postprocessor my code is

 Postprocessor getEventColorProcessor = new BasePostprocessor() {
            @Override
            public String getName() {
                return "getEventColorProcessor";
            }
            @Override
            public void process(Bitmap bitmap) {

                Palette p = Palette.from(bitmap).generate();
                if (position == 0) {
                    BusProvider.getInstance().post(new ChangeColorEvent(p.getVibrantColor(0x000000)));
                }
                holder.mAttendingNumber.setTextColor(p.getVibrantColor(0x000000));
            }
        };

        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(events.get(position).getEventImage()))
                .setPostprocessor(getEventColorProcessor)
                .build();

        PipelineDraweeController controller = (PipelineDraweeController)
                Fresco.newDraweeControllerBuilder()

                        .setImageRequest(request)
                        .setOldController(holder.mEventImage.getController())
                        .build();
        holder.mEventImage.setController(controller);

andrijans avatar May 23 '15 15:05 andrijans

  • Use a ControllerListener as shown here http://frescolib.org/docs/listening-download-events.html#_
  • Note that "onFinalImageSet()" of the ControllerListener would be the ideal place to fire the event and not the postProcessor. If you are using a DraweeView the image would be set in the view automatically.
  • To learn more about the usage of Postprocessor, refer to this:http://frescolib.org/docs/modifying-image.html#_

Hope this answers your question. Please feel free to point out anything which is not clear.

TarangS avatar May 26 '15 16:05 TarangS

The documentation you refer to seems to be out of date.

Fresco.newControllerBuilder() does not seem to exist in 0.5.2

I can instead call Fresco.newDraweeControllerBuilder(), however that returns a PipelineDraweeControllerBuilder and the sample code showing

mSimpleDraweeView.setController(controller);

will fail because setController only takes a DraweeController as an arguement.

LarsLiden avatar Jun 16 '15 20:06 LarsLiden