GIF and JPG are in recyclerview
I want to do fitXY but gif is small --> git
recyclerview item layout
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="170dp"
app:actualImageScaleType="fitXY"/>
</android.support.constraint.ConstraintLayout>
recyclerview adapter
@Override
public void onBindViewHolder(GallaryAdapter.ViewHolder holder, int position) {
final CharacterData data = characterData.get(position);
if(data.getType() == CharacterData.TYPE_GIF){
holder.imageView.setController(Fresco.newDraweeControllerBuilder()
.setUri(data.getUri())
.setAutoPlayAnimations(true)
.build());
}else{
holder.imageView.setImageURI(data.getUri());
}
}
Thank you for your help.
Hi, @JinohK, thank you for reporting this issue. I was able to reproduce it in our showcase app. Looks like we don't support downsampling of gifs.
@dmitry-voronkevich Have any plans to fix it?
Downsampling / resizing for GIFs is indeed not supported. Pull requests are welcomed :)
@oprisnik I want to implement the "resizing for Webp" feature, Could you give us some idea or suggestions.
I'm assuming you mean animated WebPs and not static ones @s1rius.
The simplest way to get this to work is to adapt WebPImage. It implements the AnimatedImage interface, which holds image dimensions, frame metadata and AnimatedImageFrames. Instead of returning values for the original image, you'd have to return values for the resized image. AnimatedImageFrame (or more specifically WebPFrame in this case) is then used to draw frames to a bitmap, which you'd have to adapt to draw a resized version instead.
This operation (as most of the other ones) is done in native code, see webp.cpp
It might be easier and more performant to downsample the image instead of performing actual resizing since you don't need to recompute all pixels.
Some background information on how this ties into the system:
Currently, animated images are backed by BitmapAnimationBackend, which internally uses a BitmapFrameRenderer to render specific frames. Since multiple frames can overlap but we need to render the full frame, the AnimatedImageCompositor composes such a full frame. It looks at all partial frames that are required for the current animation time and assembles the final bitmap to be rendered. In order to do this composition, the information for each frame and rendering is implemented by AnimatedImage, which has 2 implementations WebPImage and GifImage.
For passing down the resized dimension, you could utilize a custom decoder, see http://frescolib.org/docs/customizing-image-formats.html
Thanks a lot, I will try.
@s1rius Any further outcome?