Reputation: 514
I'm currently developing an android app, that converts normal gif-files to videos. But after some research I didn't find any good examples or hints. I've seen some existing apps, that have that functionality, so I'm sure there is a way, but in my opinion the most apps are inconsistent and buggy. Does anyone have an example, how it's done?
Regards Marc
Upvotes: 0
Views: 1045
Reputation: 1504
class ACT_GIF_MOV extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setView();
}
void setView()
{
InputStream stream = null;
try {
stream = getAssets().open("animation.gif");
}
catch (IOException e)
{
e.printStackTrace();
}
GifMovieView view = new GifMovieView(this, stream);
setContentView(view);
}
class GifMovieView extends View
{
private Movie mMovie;
InputStream mStream;
long mMoviestart=0;
public GifMovieView(Context context, InputStream stream)
{
super(context);
mStream = stream;
mMovie = Movie.decodeStream(mStream);
}
@Override protected void onDraw(Canvas canvas)
{
canvas.drawColor(Color.TRANSPARENT);
super.onDraw(canvas);
final long now = SystemClock.uptimeMillis();
if (mMoviestart == 0) { mMoviestart = now; }
final int relTime = (int)((now - mMoviestart) % mMovie.duration()); mMovie.setTime(relTime);
mMovie.draw(canvas, 10, 10); this.invalidate();
}
}
}
Upvotes: 1