libpgf
6.12.24
PGF - Progressive Graphics File
|
00001 /* 00002 * The Progressive Graphics File; http://www.libpgf.org 00003 * 00004 * $Date: 2006-05-18 16:03:32 +0200 (Do, 18 Mai 2006) $ 00005 * $Revision: 194 $ 00006 * 00007 * This file Copyright (C) 2006 xeraina GmbH, Switzerland 00008 * 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE 00011 * as published by the Free Software Foundation; either version 2.1 00012 * of the License, or (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 */ 00023 00028 00029 #ifndef PGF_WAVELETTRANSFORM_H 00030 #define PGF_WAVELETTRANSFORM_H 00031 00032 #include "PGFtypes.h" 00033 #include "Subband.h" 00034 00036 // Constants 00037 #define FilterWidth 5 ///< number of coefficients of the row wavelet filter 00038 #define FilterHeight 3 ///< number of coefficients of the column wavelet filter 00039 00040 #ifdef __PGFROISUPPORT__ 00041 00042 00043 00044 00045 class CRoiIndices { 00046 friend class CWaveletTransform; 00047 00050 CRoiIndices() 00051 : m_nLevels(0) 00052 , m_indices(0) 00053 {} 00054 00057 ~CRoiIndices() { Destroy(); } 00058 00059 void Destroy() { delete[] m_indices; m_indices = 0; } 00060 void CreateIndices(); 00061 void ComputeIndices(UINT32 width, UINT32 height, const PGFRect& rect); 00062 const PGFRect& GetIndices(int level) const { ASSERT(m_indices); ASSERT(level >= 0 && level < m_nLevels); return m_indices[level]; } 00063 void SetLevels(int levels) { ASSERT(levels > 0); m_nLevels = levels; } 00064 void ComputeTileIndex(UINT32 width, UINT32 height, UINT32 pos, bool horizontal, bool isMin); 00065 00066 public: 00070 UINT32 GetNofTiles(int level) const { ASSERT(level >= 0 && level < m_nLevels); return 1 << (m_nLevels - level - 1); } 00071 00072 private: 00073 int m_nLevels; 00074 PGFRect *m_indices; 00075 00076 }; 00077 #endif //__PGFROISUPPORT__ 00078 00079 00084 class CWaveletTransform { 00085 friend class CSubband; 00086 00087 public: 00094 CWaveletTransform(UINT32 width, UINT32 height, int levels, DataT* data = NULL); 00095 00098 ~CWaveletTransform() { Destroy(); } 00099 00106 OSError ForwardTransform(int level, int quant); 00107 00116 OSError InverseTransform(int level, UINT32* width, UINT32* height, DataT** data); 00117 00122 CSubband* GetSubband(int level, Orientation orientation) { 00123 ASSERT(level >= 0 && level < m_nLevels); 00124 return &m_subband[level][orientation]; 00125 } 00126 00127 #ifdef __PGFROISUPPORT__ 00128 00129 00130 00131 void SetROI(const PGFRect& rect); 00132 00136 const PGFRect& GetTileIndices(int level) const { return m_ROIindices.GetIndices(level); } 00137 00141 UINT32 GetNofTiles(int level) const { return m_ROIindices.GetNofTiles(level); } 00142 00146 const PGFRect& GetROI(int level) const { return m_subband[level][LL].GetROI(); } 00147 00148 #endif // __PGFROISUPPORT__ 00149 00150 private: 00151 void Destroy() { 00152 delete[] m_subband; m_subband = 0; 00153 #ifdef __PGFROISUPPORT__ 00154 m_ROIindices.Destroy(); 00155 #endif 00156 } 00157 void InitSubbands(UINT32 width, UINT32 height, DataT* data); 00158 void ForwardRow(DataT* buff, UINT32 width); 00159 void InverseRow(DataT* buff, UINT32 width); 00160 void LinearToMallat(int destLevel,DataT* loRow, DataT* hiRow, UINT32 width); 00161 void MallatToLinear(int srcLevel, DataT* loRow, DataT* hiRow, UINT32 width); 00162 00163 #ifdef __PGFROISUPPORT__ 00164 CRoiIndices m_ROIindices; 00165 #endif //__PGFROISUPPORT__ 00166 00167 int m_nLevels; 00168 CSubband (*m_subband)[NSubbands]; 00169 }; 00170 00171 #endif //PGF_WAVELETTRANSFORM_H