koral-- / android-gif-drawable

Views and Drawable for displaying animated GIFs on Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there any way to flip GifDrawable horizontally/vertically?

Mouadabdelghafouraitali opened this issue · comments

Hi, thank you for this library.

Is there any way I can flip the GifDrawable horizontally or vertically?

I tried to find a way to use preScale() method, but there's no setMatrix() method to use it.

Thank you

Sorry for the delay, you can set the matrix inside the Transform object. Like that:

fullSizeDrawable.transform = object : Transform {
    lateinit var matrix: Matrix
    override fun onBoundsChange(bounds: Rect) {
        matrix = Matrix().apply {
            postScale(
                -1f,
                1f,
                bounds.exactCenterX(),
                bounds.exactCenterY()
            )
        }
    }

    override fun onDraw(canvas: Canvas, paint: Paint, buffer: Bitmap) {
        canvas.drawBitmap(buffer, matrix, paint)
    }

}