#include <HxImageSeq.h>
Public Methods | |
| HxImageSeq () | |
| Constructor. More... | |
| HxImageSeq (HxString filename, int bufSize=0) | |
| Construct sequence from given file. More... | |
| HxImageSeq (const HxImageSeq &rhs) | |
| Copy constructor. More... | |
| virtual | ~HxImageSeq () |
| Destructor. More... | |
| HxImageSeq & | operator= (const HxImageSeq &rhs) |
| Assignment operator. More... | |
| int | ident () const |
| The identity of the sequence. More... | |
| int | isNull () const |
| Indicates wether this is a valid sequence. More... | |
| int | frameWidth () const |
| The frame width. More... | |
| int | frameHeight () const |
| The frame height. More... | |
| int | frameDepth () const |
| The frame depth. More... | |
| int | nrFrames () const |
| The number of frames. More... | |
| HxImageRep | getFrame (int nr) const |
| Get the specified frame as HxImageRep. More... | |
| void | getRgb2d (int nr, int *pixels, HxString displayMode) const |
| Display the specified frame in the given buffer in ARGB format using the given displayMode. More... | |
| void | getRgbPixels2d (int nr, int *pixels, HxString displayMode, int resWidth=-1, int resHeight=-1, HxGeoIntType gi=NEAREST) const |
| Display the specified frame in the given buffer in ARGB format using the given displayMode at the given resolution. More... | |
| HxImageSeqIter | begin () |
| An iterator pointing to the first frame. More... | |
| HxImageSeqIter | end () |
| An iterator pointing beyond the last frame. More... | |
| int | writeFile (std::vector< int > frameList, HxString filename, int format) |
| Write the frame from the list to the given file in the given format. More... | |
| STD_OSTREAM & | put (STD_OSTREAM &os) const |
| Put some information on the given stream. More... | |
Static Public Methods | |
| void | setUseMDC (int flag) |
| Indicate whether the MDC library should be used to decode mpeg files (when it is available :-). More... | |
Static Public Attributes | |
| const int | MPEG_F = 1 |
| const int | MIR_F = 2 |
| const int | AVI_F = 3 |
Friends | |
| class | HxImageSeqIter |
Supported types:
|
|
Constructor.
00032 : _pointee(0)
00033 {
00034 }
|
|
||||||||||||
|
Construct sequence from given file. bufSize: the size of the internal buffer. The buffer stores frames converted to HxImageRep's for later references. In the current implementation only contiguous frames are kept. The default is no buffering.
00036 : _pointee(0)
00037 {
00038 #ifndef __GNUC__
00039 int pos = filename.rfind(".");
00040 if (pos >=0 ) {
00041 HxString ext = filename.substr(pos);
00042 for (HxString::iterator i = ext.begin(); i!= ext.end(); i++)
00043 *i = toupper(*i);
00044 if (ext.compare(".MIR")==0) {
00045 _pointee = new HxImageSeqMir(filename, bufSize);
00046 }
00047 else if (ext.compare(".AVI")==0 || ext.compare(".AVS")==0 || ext.compare(".VDR")==0) {
00048 _pointee = new HxImageSeqAVIMedia(filename, bufSize);
00049 }
00050 else {
00051 HxImageSeqData* seq;
00052 if (_useMDC)
00053 seq = new HxImageSeqMDC(filename, bufSize);
00054 else
00055 seq = new HxImageSeqDXMedia(filename, bufSize);
00056 if(seq->valid())
00057 _pointee = seq;
00058 else
00059 delete seq;
00060 }
00061 } else {
00062 HxEnvironment::instance()->errorStream()
00063 << "No extension found in " << filename << STD_ENDL;
00064 HxEnvironment::instance()->flush();
00065 }
00066 #else
00067 HxImageSeqMDC* seq = new HxImageSeqMDC(filename, bufSize);
00068 if(seq->valid())
00069 _pointee = seq;
00070 else
00071 delete seq;
00072 #endif
00073 }
|
|
|
Copy constructor.
00081 : _pointee(rhs.pointee()) 00082 { 00083 } |
|
|
Destructor.
00086 {
00087 }
|
|
|
Indicate whether the MDC library should be used to decode mpeg files (when it is available :-). Default is false.
00077 {
00078 _useMDC = flag;
00079 }
|
|
|
Assignment operator.
00091 {
00092 _pointee = rhs._pointee;
00093 return *this;
00094 }
|
|
|
The identity of the sequence.
00104 {
00105 return pointee() ? pointee()->ident() : 0;
00106 }
|
|
|
Indicates wether this is a valid sequence.
00098 {
00099 return !int(_pointee);
00100 }
|
|
|
The frame width.
00110 {
00111 return pointee() ? pointee()->frameWidth() : 0;
00112 }
|
|
|
The frame height.
00116 {
00117 return pointee() ? pointee()->frameHeight() : 0;
00118 }
|
|
|
The frame depth.
00122 {
00123 return pointee() ? pointee()->frameDepth() : 0;
00124 }
|
|
|
The number of frames.
00128 {
00129 return pointee() ? pointee()->nrFrames() : 0;
00130 }
|
|
|
Get the specified frame as HxImageRep.
00134 {
00135 return pointee() ? pointee()->getFrame(nr) : HxImageRep();
00136 }
|
|
||||||||||||||||
|
Display the specified frame in the given buffer in ARGB format using the given displayMode. The pixels buffer has to be allocated by the class user and should have sufficient size.
00140 {
00141 if (!pointee()) return;
00142
00143 pointee()->getRgb2d(nr, pixels, displayMode);
00144 }
|
|
||||||||||||||||||||||||||||
|
Display the specified frame in the given buffer in ARGB format using the given displayMode at the given resolution. The pixels buffer has to be allocated by the class user and should have sufficient size.
00149 {
00150 if (!pointee()) return;
00151
00152 pointee()->getRgbPixels2d(nr, pixels, displayMode, resWidth, resHeight, gi);
00153 }
|
|
|
An iterator pointing to the first frame.
00157 {
00158 return HxImageSeqIter(this, 0);
00159 }
|
|
|
An iterator pointing beyond the last frame.
00163 {
00164 return HxImageSeqIter(this, pointee()->nrFrames());
00165 }
|
|
||||||||||||||||
|
Write the frame from the list to the given file in the given format. Currently, only MIR format is implemented.
00169 {
00170
00171 #ifndef __GNUC__
00172
00173 if (format==MIR_F) {
00174 Header_Type* header = new Header_Type;
00175 strcpy(header->id,"MIR");
00176 header->width = frameWidth();
00177 header->height = frameHeight();
00178 header->depth = frameDepth();
00179 header->no_of_frames = frameList.size();
00180
00181 FILE *fp = fopen(filename.c_str(),"w+b");
00182 if (!fp) {
00183 HxEnvironment::instance()->errorStream()
00184 << "Cannot open file for writing:" << filename << STD_ENDL;
00185 HxEnvironment::instance()->flush();
00186 return -1;
00187 }
00188
00189 int* buf = new int[header->width * header->height];
00190 int block_size = header->width * header->height * sizeof(int);
00191
00192 fwrite(header,sizeof(Header_Type),1,fp);
00193
00194 for (int i=0; i<frameList.size(); i++) {
00195 HxImageRep im = pointee()->frame2HxImageRep(frameList[i]);
00196 im.getRgbPixels2d(buf,"Direct");
00197 fwrite(buf, block_size, 1, fp);
00198 }
00199 fclose(fp);
00200
00201 delete buf;
00202
00203 return 0;
00204 }
00205 else if (format==AVI_F) {
00206 HxEnvironment::instance()->errorStream()
00207 << "Cannot (yet) write AVI files :" << filename << STD_ENDL;
00208 HxEnvironment::instance()->flush();
00209 return -1;
00210 }
00211
00212 else {
00213 HxEnvironment::instance()->errorStream()
00214 << "Writefile for this format not implemented yet" << STD_ENDL;
00215 HxEnvironment::instance()->flush();
00216 return -1;
00217 }
00218
00219 #else
00220
00221 HxEnvironment::instance()->errorStream()
00222 << "No non DX codec" << STD_ENDL;
00223 HxEnvironment::instance()->flush();
00224 return -1;
00225
00226 // __GNUC__
00227 #endif
00228 }
|
|
|
Put some information on the given stream.
00232 {
00233 os << "Number of Frames: " << nrFrames()
00234 << ", frame sizes : " << frameWidth() << " x " << frameHeight()
00235 << STD_ENDL;
00236 return os;
00237 }
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001