Open JinohK opened 6 years ago
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 AnimatedImageFrame
s. 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?
@s1rius It is not working for animated webp.
The method doesRenderSupportScaling
in WebPImage
return true so that it does not go into renderImageDoesNotSupportScaling
in AnimatedDrawableBackendImpl
. Maybe the method doesRenderSupportScaling
in WebPImage
should return false?
GIF and JPG are in recyclerview
I want to do fitXY but gif is small --> git
recyclerview item layout
recyclerview adapter
Thank you for your help.