00001 #ifndef Impala_Core_Array_ImageArchive_h
00002 #define Impala_Core_Array_ImageArchive_h
00003
00004 #include "Basis/ILog.h"
00005 #include "Core/Array/Arrays.h"
00006
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace Array
00012 {
00013
00014
00015 class ImageArchive
00016 {
00017 public:
00018
00019 ImageArchive()
00020 {
00021 }
00022
00023 virtual
00024 ~ImageArchive()
00025 {
00026 }
00027
00028 virtual bool
00029 Valid()
00030 {
00031 return false;
00032 }
00033
00034 virtual int
00035 NrImages()
00036 {
00037 return 0;
00038 }
00039
00040
00041 virtual Array2dVec3UInt8*
00042 ReadImage(int idx)
00043 {
00044 return 0;
00045 }
00046
00047
00048 virtual UInt8*
00049 GetImageData(int idx, size_t& blockSize)
00050 {
00051 return 0;
00052 }
00053
00054
00055
00056 virtual std::vector<Array::Array2dScalarUInt8*>*
00057 GetImageDataList()
00058 {
00059 return 0;
00060 }
00061
00062 int
00063 Diff(ImageArchive* arg)
00064 {
00065 if (NrImages() != arg->NrImages())
00066 {
00067 ILOG_ERROR("Diff: nrImages differs: " << NrImages() << " vs " <<
00068 arg->NrImages());
00069 return 1;
00070 }
00071 int nDiff = 0;
00072 for (int i=0 ; i<NrImages() ; i++)
00073 {
00074 size_t size1 = 0;
00075 UInt8* data1 = GetImageData(i, size1);
00076 size_t size2 = 1;
00077 UInt8* data2 = arg->GetImageData(i, size2);
00078 if (size1 != size2)
00079 {
00080 ILOG_DEBUG("image " << i << " size differs " << size1 << " vs "
00081 << size2);
00082 nDiff++;
00083 }
00084 else
00085 {
00086 for (int j=0 ; j<size1 ; j++)
00087 {
00088 if (data1[j] != data2[j])
00089 {
00090 ILOG_DEBUG("image " << i << " byte " << j << " differs");
00091 nDiff++;
00092 break;
00093 }
00094 }
00095 }
00096 delete data1;
00097 delete data2;
00098 }
00099 if (nDiff > 0)
00100 ILOG_ERROR("Diff: found " << nDiff << " differences");
00101 return nDiff;
00102 }
00103
00104 private:
00105
00106 ILOG_VAR_DEC;
00107 };
00108
00109 ILOG_VAR_INIT(ImageArchive, Impala.Core.Array);
00110
00111 }
00112 }
00113 }
00114
00115 #endif