Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

animation.h

Go to the documentation of this file.
00001 /*
00002  * RVE: Realtime Video Effects
00003  * Copyright (C) 2002 Jonas Jensen <jbj@knef.dk>
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00026 #ifndef _ANIMATION_H
00027 #define _ANIMATION_H
00028 
00029 #include <memory>
00030 #include <vector>
00031 
00032 #include "bitmap.h"
00033 
00047 class Animation {
00048 public:
00049     Animation(): _nextframe(NULL), _lastframe(NULL), _same_size(1),
00050         _firstw(0), _firsth(0) {}
00051     virtual ~Animation() { delete _lastframe; }
00052 
00065     virtual const Bitmap *next(int skip = 0);
00066 
00071     virtual const Bitmap *peek(int skip = 0);
00072 
00074     virtual int w();
00076     virtual int h();
00077 
00082     virtual int same_size(int set = -1);
00083 
00084 protected:
00085     virtual Bitmap *getframe(int skip = 0) = 0;
00086     virtual int autofree() { return 1; }
00087 
00088     const Bitmap *_nextframe;
00089     const Bitmap *_lastframe;
00090 
00091     int _same_size, _firstw, _firsth;
00092 };
00093 
00099 class LoopingFrames: public Animation {
00100 public:
00101     virtual ~LoopingFrames();
00102 
00106     void insert_frame(const Bitmap &bitmap);
00107 
00108 protected:
00109     virtual Bitmap *getframe(int skip = 0);
00110     virtual int autofree() { return 0; }
00111 
00112     std::vector<Bitmap *> _frames;
00113     unsigned int _pos;
00114 };
00115 
00120 class RollCount: public Animation {
00121 public:
00122     RollCount(): _ready(0) {}
00123     //virtual ~RollCount();
00124 
00145     void param(int fps, int from, int digits, int groupspacing = 5,
00146             RGBA *background = NULL, int marginx = 0, int marginy = 0,
00147             int shift = 0, int digitsize = 0) {
00148         _fps = fps; _from = abs(from); _digits = digits; 
00149         _groupspacing = groupspacing; _marginx = marginx; _marginy = marginy;
00150         _shift = shift; _digitsize = digitsize;
00151         if (background)
00152             _background.reset((RGBA *)background->clone());
00153 
00154         _frameno = _from*_fps;
00155         _ready = 1;
00156     }
00157 
00158 protected:
00159     virtual Bitmap *getframe(int skip = 0);
00160     void prepare();
00161     
00162     int _fps, _from, _digits, _groupspacing, _marginx, _marginy, _shift;
00163     int _digitsize;
00164     
00165     RGBA _figures[10], _empty;
00166     std::auto_ptr<RGBA> _background;
00167     int _ready, _frameno, _maxw, _maxh;
00168 };
00169 
00170 #endif

Generated on Sun Oct 19 17:34:47 2003 for rve by doxygen 1.3.3