Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i get all bitmap frame from animate webp #125

Open
wujinsheng-ola opened this issue Jan 18, 2024 · 1 comment
Open

how can i get all bitmap frame from animate webp #125

wujinsheng-ola opened this issue Jan 18, 2024 · 1 comment

Comments

@wujinsheng-ola
Copy link

wujinsheng-ola commented Jan 18, 2024

i want to get all bitmap frame from animate webp ,then i can convert each bitmap to nine patch drawable ,thus i can implement animate nine patch chat bubble。just like this:

Glide.with(viewBind.tvWebpNinePatch).load(animatedWebpUrl)
            .optionalTransform(WebpDrawable::class.java, WebpDrawableTransformation(object : Transformation<Bitmap> {
                override fun updateDiskCacheKey(messageDigest: MessageDigest) {
                }

                override fun transform(context: Context, resource: Resource<Bitmap>, outWidth: Int, outHeight: Int): Resource<Bitmap> {
                    val frame = resource.get()
                    val drawable = NinePatchDrawableBuilder(bitmap = frame, resources)
                        .setHorizontalStretchBean(PatchStretchBean(60, 61))//水平拉伸区域
                        .setVerticalStretchBean(PatchStretchBean(52, 53))//垂直拉伸区域
                        .setOriginSize(128, 112)//原始图片大小
                        .setPadding(Rect(31, 37, 90, 75))//padding区域
                        .setHorizontalMirror(true)//是否水平镜像,不是必须的
                        .get9PatchDrawable()
                    viewBind.tvWebpNinePatch.background = drawable
                    return resource
                }
            }))
            .into(object : CustomViewTarget<View?, Drawable?>(viewBind.tvWebpNinePatch) {
                override fun onLoadFailed(errorDrawable: Drawable?) {

                }

                override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable?>?) {
//                    getView().background = resource
                }

                override fun onResourceCleared(placeholder: Drawable?) {}
            }) 

i can not get each frame from transform。 please help me ,thanks very much

@zjupure
Copy link
Owner

zjupure commented Jan 29, 2024

It's not support, WebpDrawable manage the frame bitmap and drive it to animate. If you want to animate the nine patch drawable, you might write a custom nine patch drawable to draw webp bitmap into canvas and invalidate it continually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants