| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeDecoderTIFF.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00027 #ifndef  __TERRALIB_INTERNAL_DECODERTIFF_H
    00028 #define  __TERRALIB_INTERNAL_DECODERTIFF_H
    00029
    00030 #include "TeDecoder.h"
    00031 #include "TeDecoderSmartMem.h"
    00032
    00033 // LibTIFF includes
    00034 #include "geotiff.h"
    00035 #include "xtiffio.h"
    00036
    00037
    00039
    00049 class TL_DLL TeDecoderTIFF: public TeDecoder
    00050 {
    00051            TIFF       *tif;                            // TIFF directory structure
    00052            GTIF       *gtif;                           // GEOTIFF directory structure
    00053
    00054            unsigned char** dataBuffer_;     // buffer to hold decoded data
    00055                                                        // for tile data it holds 1 tile
    00056                                                        // for stripped data it holds 1 strip with all the planes
    00057
    00058            unsigned int          nplanes_;  // number of planes or logical division of the data within the files
    00059
    00060            bool                  isGeoTiff_;           // indicates if the data has geographical information
    00061            short                 TImage_;   // 0=MONOIMAGE, 1=RGBIMAGE, 2=PALLETE
    00062            unsigned short        planar_;   // storage organization : PLANARCONFIG_CONTIG or PLANARCONFIG_SEPARATE
    00063
    00064            bool                  isTiled_;  // indicates if the data is organizes in tiles
    00065            unsigned long         tilew_,tileh_;        // tile and height
    00066            unsigned long         tilesacross_;         // number of tiles to compose a row of image
    00067            unsigned long         bytespertile_;        // number of bytes per tile
    00068            long                  TCurTile_; // current tile decoded in internal memory
    00069
    00070            unsigned long         rowsperstrip_;        // number of rows per strip
    00071            unsigned long         nstripsperplane_;     // number of strips per plane of data
    00072            unsigned long         stripsize_;           // number of bytes per strip
    00073            long                  TCurStrip_;           // current line in memory
    00074
    00075            unsigned int          nBands_;              // number of samples per data
    00076
    00077            // This is an internal smart manager to support the creation of tiffs
    00078            TeDecoderSmartMem memManager_;
    00079
    00080            //         Reads TIFF Directory and fills tif structure
    00081            void readTiffDirectory();
    00082
    00083            // Reads the georeferencing keys of a geotiff data
    00084            bool getGeoTIFF();
    00085
    00086            // Sets the georeferencing keys of a geotiff data
    00087            void setGeoKeys();
    00088
    00089            // Reads LUT information
    00090            bool readLut();
    00091
    00092            // Saves LUT information
    00093            void saveLut();
    00094
    00095            // Reads enough tiles to compose a row of data
    00096            bool readTileImageContig(unsigned long tiler);
    00097
    00098            // Reads a strip
    00099            bool readStrip(unsigned long strip);
    00100
    00101            // Allocates te internal memory
    00102            bool allocateWorkMemory();
    00103
    00105            typedef void (TeDecoderTIFF::*GetEleFunctPtrT)( const long& plane, const long& pos, double& val );
    00106
    00108            GetEleFunctPtrT getelement_ptr_;
    00109
    00111            unsigned char** data_TeUNSIGNEDCHAR_;
    00112
    00114            char** data_TeCHAR_;
    00115
    00117            unsigned short** data_TeUNSIGNEDSHORT_;
    00118
    00120            short** data_TeSHORT_;
    00121
    00123            int** data_TeINTEGER_;
    00124
    00126            unsigned long** data_TeUNSIGNEDLONG_;
    00127
    00129            long** data_TeLONG_;
    00130
    00132            float** data_TeFLOAT_;
    00133
    00135            double** data_TeDOUBLE_;
    00136
    00137            inline void getElement_TeUNSIGNEDCHAR(const long& plane, const long& pos, double& val );
    00138
    00139            inline void getElement_TeCHAR(const long& plane, const long& pos, double& val );
    00140
    00141            inline void getElement_TeUNSIGNEDSHORT(const long& plane, const long& pos, double& val );
    00142
    00143            inline void getElement_TeSHORT(const long& plane, const long& pos, double& val );
    00144
    00145            inline void getElement_TeINTEGER(const long& plane, const long& pos, double& val );
    00146
    00147            inline void getElement_TeUNSIGNEDLONG( const long& plane, const long& pos, double& val );
    00148
    00149            inline void getElement_TeLONG(const long& plane, const long& pos, double& val );
    00150
    00151            inline void getElement_TeFLOAT(const long& plane, const long& pos, double& val );
    00152
    00153            inline void getElement_TeDOUBLE(const long& plane, const long& pos, double& val );
    00154
    00155 public:
    00156
    00158            TeDecoderTIFF( const TeRasterParams& );
    00159
    00161            ~TeDecoderTIFF();
    00162
    00164            void init();
    00165
    00167            bool clear();
    00168
    00170            bool setElement (int col,int lin, double val, int band=0);
    00171
    00173            bool getElement (int col,int lin, double &val,int band=0);
    00174 };
    00175
    00177 class TL_DLL TeDecoderTIFFFactory : public TeDecoderFactory
    00178 {
    00179 public:
    00180
    00181            TeDecoderTIFFFactory(const string& name);
    00182
    00183            TeDecoder* build (const TeRasterParams& arg)
    00184            {  return new TeDecoderTIFF(arg); }
    00185 };
    00186
    00187 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines