Fresco: Fresco customization is not working on setImageBitmap (without ImageUri)

Created on 30 Jun 2015  路  6Comments  路  Source: facebook/fresco

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.

needs-details

Most helpful comment

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.

All 6 comments

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

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

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.

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.

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

qiiyue picture qiiyue  路  4Comments

stevenmtang picture stevenmtang  路  3Comments

bigfreeZhou picture bigfreeZhou  路  4Comments

ykostova picture ykostova  路  3Comments

eldk picture eldk  路  3Comments