Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
780 views
in Technique[技术] by (71.8m points)

android - Define zoom/pan start position with KenBurnsView

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to implement your own TransitionGenerator and override generateNextTransition() from where you must return a Transition object.

The generateNextTransition() method takes:

  1. RectF drawableBounds: the bounds of the drawable that is set to the KenBurnsView;

  2. RectF viewport the bounds of the KenBurnsView object.

The Transition constructor takes:

  1. RectF srcRect: a subrectangle of the drawable that will fill the whole KenBurnsView when the transition starts (illustrated below):

Ken Burns effect

Illustration from Wikipedia

  1. RectF dstRect: a subrectangle of the drawable that will fill the whole KenBurnsView when the transition ends;

  2. long duration: the duration, in milliseconds, of the transition.

  3. 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...