00001 #ifndef Impala_Core_Stream_RgbDataSrcRaw_h
00002 #define Impala_Core_Stream_RgbDataSrcRaw_h
00003
00004 #include "Core/Stream/RgbDataSrc.h"
00005 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00006 #include "Core/Array/ImageArchiveFile.h"
00007 #else // REPOSITORY_USED
00008 #include "Core/Array/ImageArchive.h"
00009 #endif // REPOSITORY_USED
00010
00011 namespace Impala
00012 {
00013 namespace Core
00014 {
00015 namespace Stream
00016 {
00017
00018
00019 class RgbDataSrcRaw : public RgbDataSrc
00020 {
00021
00022 public:
00023
00024 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00025 RgbDataSrcRaw(CString fName, bool useMemory=false) : RgbDataSrc(20, fName)
00026 {
00027 Init(fName, useMemory);
00028 }
00029 #else // REPOSITORY_USED
00030 RgbDataSrcRaw(int src, CString srcName, Array::ImageArchive* archive)
00031 : RgbDataSrc(src, srcName)
00032 {
00033 Init(archive);
00034 }
00035 #endif // REPOSITORY_USED
00036
00037 virtual
00038 ~RgbDataSrcRaw()
00039 {
00040 if (mCurIm)
00041 delete mCurIm;
00042 if (mArchive)
00043 delete mArchive;
00044 }
00045
00046 virtual bool
00047 Valid() const
00048 {
00049 return mArchive->Valid();
00050 }
00051
00052
00053 protected:
00054
00055 bool
00056 ReadFrameData()
00057 {
00058 if (mCurIm)
00059 delete mCurIm;
00060 mCurIm = mArchive->ReadImage(FrameNr());
00061 if (!mCurIm)
00062 {
00063 ILOG_ERROR("unable to read frame " << FrameNr());
00064 return false;
00065 }
00066
00067
00068
00069 mFrameWidth = mCurIm->CW();
00070 mFrameHeight = mCurIm->CH();
00071
00072 mData = mCurIm->CPB();
00073 return true;
00074 }
00075
00076
00077 private:
00078
00079 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00080 void
00081 Init(CString fName, bool useMemory)
00082 {
00083 mCurIm = 0;
00084 mArchive = new Array::ImageArchiveFile(fName, useMemory,
00085 &Util::Database::GetInstance());
00086 #else // REPOSITORY_USED
00087 void
00088 Init(Array::ImageArchive* archive)
00089 {
00090 mCurIm = 0;
00091 mArchive = archive;
00092 #endif // REPOSITORY_USED
00093 mLastFrame = mArchive->NrImages() - 1;
00094
00095 Array::Array2dVec3UInt8* im = mArchive->ReadImage(0);
00096 if (im == 0)
00097 {
00098 ILOG_ERROR("Unable to read image");
00099 return;
00100 }
00101
00102 mFrameWidth = im->CW();
00103 mFrameHeight = im->CH();
00104 delete im;
00105 }
00106
00107 Array::Array2dVec3UInt8* mCurIm;
00108 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00109 Array::ImageArchiveFile* mArchive;
00110 #else // REPOSITORY_USED
00111 Array::ImageArchive* mArchive;
00112 #endif // REPOSITORY_USED
00113
00114 ILOG_VAR_DEC;
00115 };
00116
00117 ILOG_VAR_INIT(RgbDataSrcRaw, Impala.Core.Stream);
00118
00119 }
00120 }
00121 }
00122
00123 #endif