I'm working with the library KenBurnsView and I have a problem:
the overview or this nice library says the following: "Highly extensible: you can define how the rectangles to be zoomed and panned will be generated"
and that's exactly what I want to do but I don't know exactly how.
I would like to be able to tell the library to zoom or pan from a specified region (a RectF I presume) of my image.
I think I have to implements my own TransitionGenerator and write a custom generateNextTransition() mtehod but I don't know what to do inside.
Can anyone help me ?
Thanks.
Adrian
You need to implement your own TransitionGenerator
and override generateNextTransition()
from where you must return a Transition
object.
The generateNextTransition()
method takes:
RectF drawableBounds
: the bounds of the drawable that is set to the KenBurnsView
;
RectF viewport
the bounds of the KenBurnsView
object.
The Transition
constructor takes:
RectF srcRect
: a subrectangle of the drawable that will fill the whole KenBurnsView
when the transition starts (illustrated below):
Illustration from Wikipedia
RectF dstRect
: a subrectangle of the drawable that will fill the whole KenBurnsView
when the transition ends;
long duration
: the duration, in milliseconds, of the transition.
Interpolator interpolator
: an interpolator instance that will define the nature of the movement (may be an AccelerateDecelerateInterpolator
, LinearInterpolator
, etc.);
It might me a good idea to save dstRect
to be used as srcRect
in the next transition if you desire that every transition will start from the place the last transition has stopped. That's exactly what the RandomTransitionGenerator
does. Keep in mind that srcRect
and dstRect
can have different sizes (but both should be subrectangles of drawableBounds
if you want to keep the image in scene all the time). It's important that both of them have the same aspect ratio of viewport
.