fresco icon indicating copy to clipboard operation
fresco copied to clipboard

Fresco customization is not working on setImageBitmap (without ImageUri)

Open amitshekhariitbhu opened this issue 11 years ago • 6 comments

GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); GenericDraweeHierarchy hierarchy = builder .setFadeDuration(300) .setPlaceholderImage(new MyCustomDrawable()) .setBackgrounds(backgroundList) .setOverlays(overlaysList) .setActualImageFocusPoint(focusPoint); .build();

mSimpleDraweeView.setHierarchy();

mSimpleDraweeView.setImageBitmap(bitmap);

How can I get Uri for dynamically created bitmap.As I don't want to save Image to get the uri of the bitmap.

Help me how to do it.

amitshekhariitbhu avatar Jun 30 '15 04:06 amitshekhariitbhu

Where do you get the bitmap from? You shouldn't be using setImageBitmap, but I need more context in order to answer the question.

plamenko avatar Jun 30 '15 16:06 plamenko

I have created a class that takes bitmap from camera and then return bitmap after some manipulation like filters,resize,etc.In this way I get Bitmap to set on a SimpleDraweeView

amitshekhariitbhu avatar Jul 01 '15 05:07 amitshekhariitbhu

Fresco manages Bitmaps on its own, and it does not support providing Bitmap instances created elsewhere. This is necessary because of how Fresco manages memory. You could save the modified image to disk and then just normally load it with Fresco.

Alternatively, you could create a BitmapDrawable out of your Bitmap and set it as a placeholder to the SimpleDraweeView (You will also need to set the null url). With this approach however you lose all the memory benefits that Fresco provides and you may run into memory issues.

plamenko avatar Jul 08 '15 14:07 plamenko

As we know , Fresco can't resize png and the performance of loading a lot of gifs is bad for it will load the gifs and not caching them. So I desperately wanna resize the png and get the first frame of gifs and load the bitmap by fresco. But we can't do it.

AllenVork avatar May 04 '16 02:05 AllenVork

@My code uses a generated BitmapDrawable, relative to onscreen content, and its really maddening that that I can't simply set it on the Drawee. Enough so that I am about to rip out Fresco from my app.

bpappin avatar Jun 18 '17 02:06 bpappin

You can supply a custom DrawableFactory that just returns your BitmapDrawable. Example for Keyframes: https://github.com/facebook/fresco/blob/master/samples/showcase/src/main/java/com/facebook/fresco/samples/showcase/imageformat/keyframes/KeyframesDecoderExample.java#L165

oprisnik avatar Jun 18 '17 16:06 oprisnik