koral--/android-gif-drawable

Is there any way to flip GifDrawable horizontally/vertically?

Mouadabdelghafouraitali opened this issue · 1 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)
    }

}