image.h

Go to the documentation of this file.
00001 /**
00002  * \file rvc/image.h 
00003  * \brief RVC::IMAGE class definitions.
00004  *
00005  * \if NODOC
00006  * $Id: image.h_v 1.40 2004/12/03 17:04:26 scowan Exp $
00007  *
00008  * $Log: image.h_v $
00009  * Revision 1.40  2004/12/03 17:04:26  scowan
00010  * SequentialReadOptim.
00011  *
00012  * Revision 1.39  2004/12/03 16:08:25  scowan
00013  * Added image capability.
00014  *
00015  * Revision 1.38  2004/11/19 15:31:25  scowan
00016  * Setup database to exist under signed rasters.
00017  * I do not think that this is a good idea.
00018  *
00019  * Revision 1.37  2004/08/31 17:45:38  scowan
00020  * Moved chache size methods to here and made virtual methods from them.
00021  *
00022  * Revision 1.36  2004/08/30 14:10:48  mju
00023  * Add pyramid_default.
00024  *
00025  * Revision 1.35  2004/03/01 15:45:32  mju
00026  * Add pyramid_Partial flag.
00027  *
00028  * Revision 1.34  2004/02/24 16:09:20  scowan
00029  * Added two new filter cell types.
00030  *
00031  * Revision 1.33  2004/02/03 21:19:21  scowan
00032  * Added rgb spread conversion.
00033  *
00034  * Revision 1.32  2003/11/05 18:44:27  scowan
00035  * Added red blue conversion modes.
00036  *
00037  * Revision 1.31  2003/10/30 18:27:28  scowan
00038  * Added new celltype.
00039  *
00040  * Revision 1.30  2003/10/23 21:24:48  scowan
00041  * nc.
00042  *
00043  * Revision 1.29  2003/10/22 17:07:27  scowan
00044  * Removed deprecated method.
00045  *
00046  * Revision 1.28  2003/10/22 16:17:21  scowan
00047  * Added get objtype set static method.
00048  *
00049  * Revision 1.27  2003/10/15 15:08:37  scowan
00050  * Added method to convert legacy datatype and numbits to  celltype.
00051  *
00052  * Revision 1.26  2003/10/10 16:02:22  scowan
00053  * Added method to get i18n string from celltype.
00054  *
00055  * Revision 1.25  2003/09/30 16:52:06  dwilliss
00056  * Doxygen
00057  *
00058  * Revision 1.24  2003/09/25 21:56:58  dwilliss
00059  * doxygen
00060  *
00061  * Revision 1.23  2003/09/15 23:16:55  scowan
00062  * Added observer class and set null value pure virtual method.
00063  *
00064  * Revision 1.22  2003/09/15 13:49:45  fileserver!dwilliss
00065  * Doxygen
00066  *
00067  * Revision 1.21  2003/09/11 20:09:19  scowan
00068  * Added is image function.
00069  *
00070  * Revision 1.20  2003/08/27 21:26:06  scowan
00071  * Added more celltypes.
00072  *
00073  * Revision 1.19  2003/07/31 14:27:20  scowan
00074  * Added method to get celltype range.
00075  *
00076  * Revision 1.18  2003/06/27 20:39:05  scowan
00077  * Added pyramid enum.
00078  *
00079  * Revision 1.17  2003/05/07 22:19:41  scowan
00080  * Changed virtual method format.
00081  *
00082  * Revision 1.16  2002/10/17 15:23:22  mju
00083  * Add GetCellTypeFromColorSpace and GetColorSpaceFromCellType.
00084  *
00085  * Revision 1.15  2002/09/03 22:05:32  mju
00086  * Change CELLTYPE to use separable bits and add combined types for filter.
00087  *
00088  * Revision 1.14  2001/11/02 17:14:26  mju
00089  * Redesign null value.
00090  * Add CELLTYPE enum.
00091  * Add HasNullValue() pure virtual method.
00092  *
00093  * Revision 1.13  2001/10/26 13:47:58  scowan
00094  * Added default band number for get null value.
00095  *
00096  * Revision 1.12  2001/10/25 21:30:38  scowan
00097  * Added get null value as a method.
00098  *
00099  * Revision 1.11  2001/08/06 16:56:08  scowan
00100  * Nothing.
00101  *
00102  * Revision 1.10  2001/08/06 16:54:14  scowan
00103  * Temp promotion of static method for legacy applications.
00104  *
00105  * Revision 1.8  2001/06/15 15:35:10  scowan
00106  * Added get null value method that returs a double.
00107  *
00108  * Revision 1.7  2001/06/14 14:50:36  scowan
00109  * Added to RVC namespace.
00110  *
00111  * Revision 1.1  2000/10/02 17:22:56  scowan
00112  * Initial revision
00113  * \endif
00114 **/
00115 
00116 //!   \class RVC::IMAGE rvc/image.h
00117 //!   \brief Interface for RVC objects that support an multiple image band paradigm.
00118 //!
00119 //!   This includes methods to read and write to each individual image band
00120 //!
00121 //!   RVC Object Types that this class supports: Derived class
00122 //!
00123 //!   Default RVC Object Type for this class: Derived class
00124 //!
00125 //!   Valid parents for this class: Derived class
00126 
00127 #ifndef INC_RVC_IMAGE_H
00128 #define INC_RVC_IMAGE_H
00129 
00130 #ifndef INC_RVC_GEOSPATL_H
00131    #include <rvc/geospatl.h>
00132 #endif
00133 
00134 #ifndef INC_MI32_RVCRAST_H
00135    #include <mi32/rvcrast.h>
00136 #endif
00137 
00138 #ifndef INC_MI32_COLORSPC_H
00139    #include <mi32/colorspc.h>
00140 #endif
00141 
00142 #ifndef INC_MI32_RANGE_H
00143    #include <mi32/range.h>
00144 #endif
00145 
00146 
00147 namespace RVC {
00148 
00149 struct AnyCallbackStruct;
00150 
00151 class IMAGE : public RVC::GEOSPATIAL {
00152    public:
00153 
00154       enum CACHEMODE {           //! Raster cache values for SetCacheMode()
00155          CACHEMODE_Default = 0,     //!< Default cache size is 4 tiles unless compressed
00156          CACHEMODE_DiagonalRow,     //!< Sets raster cache to allocate a hypotenuse amount of tiles
00157          CACHEMODE_TileRow          //!< Default cache size if raster is compressed, caches a row of tiles
00158          };
00159 
00160       enum CAPABILITY {
00161          CAPABILITY_None =                   0,
00162          CAPABILITY_SequentialReadOptimal = 1024   //!< Image is best accessed one scanline at a time in top to bottom order
00163          };
00164          
00165       //! Possible type conversion modes for Read(), ReadColumn() and Write()
00166       enum CONVMODE {
00167          CONVMODE_None = 0,            //!< No conversion
00168          CONVMODE_ByteSpread,          //!< Convert < 8-bit to 8-bit by spreading over 0-255 range
00169          CONVMODE_INT8,                //!< Convert 1/2/4 bits to 8-bit by copy
00170          CONVMODE_INT16,               //!< Convert < INT16 to INT16 bits/cell
00171          CONVMODE_INT32,               //!< Convert < INT32 to INT32 bits/cell
00172          CONVMODE_Float,               //!< Convert to float
00173          CONVMODE_Double,              //!< Convert to double
00174          CONVMODE_RGB,                 //!< Convert to RGB, only for Read() method
00175          CONVMODE_BGR,                 //!< Convert to BGR, only for Read() method
00176          CONVMODE_RGBSpread,           //!< Convert to RGB and spread 16 to 24 bit, only for Read() method
00177          CONVMODE_BGRSpread            //!< Convert to BGR and spread 16 to 24 bit, only for Read() method
00178          };
00179 
00180       //! Valid image datatypes.
00181       enum DATATYPE {
00182          DATATYPE_Invalid = 0,         //!< Not a valid raster datatype
00183          DATATYPE_Unsigned,            //!< UINT8, UINT16, UINT32 and < 8 bit
00184          DATATYPE_Signed,              //!< INT8, INT16, INT32
00185          DATATYPE_Float,               //!< FLOAT, DOUBLE
00186          DATATYPE_BGR,                 //!< RED, GREEN, BLUE packed (blue first byte)
00187          DATATYPE_RGB,                 //!< RED, GREEN, BLUE packed (red first byte)
00188          DATATYPE_BGR16,               //!< RED, GREEN, BLUE packed (blue high bits)
00189          DATATYPE_RGB16,               //!< RED, GREEN, BLUE packed (red high bits)
00190          DATATYPE_ComplexRI,           //!< Real, Imaginary
00191          DATATYPE_ComplexMP,           //!< Magnitude, Phase
00192          DATATYPE_RGBA,                //!< RED, GREEN, BLUE packed (red first byte)
00193          DATATYPE_ARGB,                //!< RED, GREEN, BLUE packed (red first byte)
00194          DATATYPE_CMYK,                //!< RED, GREEN, BLUE packed (red first byte)
00195          DATATYPE_KCMY                 //!< RED, GREEN, BLUE packed (red first byte)
00196          };
00197 
00198       //! Image cell type enumerating valid data type and bit depth combinations.
00199       enum CELLTYPE {
00200          CELLTYPE_Invalid =                   0x00000000,
00201          CELLTYPE_Binary =                    0x00000001,
00202          CELLTYPE_Unsigned_4 =                0x00000002,
00203          CELLTYPE_Unsigned_8 =                0x00000004,
00204          CELLTYPE_Unsigned_32 =               0x00000008,
00205          CELLTYPE_Unsigned_16 =               0x00000010,
00206          CELLTYPE_Unsigned_64 =               0x00000020,
00207          CELLTYPE_Signed_8 =                  0x00000040,
00208          CELLTYPE_Signed_16 =                 0x00000080,
00209          CELLTYPE_Signed_32 =                 0x00000100,
00210          CELLTYPE_Signed_64 =                 0x00000200,
00211          CELLTYPE_Float_32 =                  0x00000400,
00212          CELLTYPE_Float_64 =                  0x00000800,
00213          CELLTYPE_ComplexRI_64 =              0x00001000,
00214          CELLTYPE_ComplexMP_64 =              0x00002000,
00215          CELLTYPE_ComplexRI_128 =             0x00004000,
00216          CELLTYPE_ComplexMP_128 =             0x00008000,
00217          CELLTYPE_X1R5G5B5_16 =               0x00010000,   //!< Packed into UINT16 with Red in high bits
00218          CELLTYPE_X1B5G5R5_16 =               0x00020000,   //!< Packed into UINT16 with Blue in high bits
00219          CELLTYPE_RedGreenBlue_24 =           0x00040000,   //!< 3 bytes, red first
00220          CELLTYPE_BlueGreenRed_24 =           0x00080000,   //!< 3 bytes, blue first
00221          CELLTYPE_RedGreenBlueAlpha_32 =      0x00100000,   //!< 4 bytes, red first
00222          CELLTYPE_AlphaRedGreenBlue_32 =      0x00200000,   //!< 4 bytes, alpha first
00223          CELLTYPE_CyanMagentaYellowBlack_32 = 0x00400000,   //!< 4 bytes, cyan first
00224          CELLTYPE_BlackCyanMagentaYellow_32 = 0x00800000,   //!< 4 bytes, black first
00225          // When add types add also to IMAGE::GetCellTypeResourceString(), IMAGE::GetCellTypeString() and IMAGE::GetCellTypeRange() in image.c.
00226          // New types should be added here
00227          // Multiple-type specifications for filters, etc.
00228          CELLTYPE_None =                      0x00000000,
00229          CELLTYPE_Unsigned_Max8 =             (CELLTYPE_Binary + CELLTYPE_Unsigned_4 + CELLTYPE_Unsigned_8),
00230          CELLTYPE_Unsigned_Max16 =            (CELLTYPE_Unsigned_Max8 + CELLTYPE_Unsigned_16),
00231          CELLTYPE_Unsigned_Max32 =            (CELLTYPE_Unsigned_Max16 + CELLTYPE_Unsigned_32),
00232          CELLTYPE_Unsigned_Max64 =            (CELLTYPE_Unsigned_Max32 + CELLTYPE_Unsigned_64),
00233          CELLTYPE_Signed_Max32 =              (CELLTYPE_Signed_8 + CELLTYPE_Signed_16 + CELLTYPE_Signed_32),
00234          CELLTYPE_Signed_Max64 =              (CELLTYPE_Signed_Max32 + CELLTYPE_Signed_64),
00235          CELLTYPE_Integer_Max32 =             (CELLTYPE_Unsigned_Max32 + CELLTYPE_Signed_Max32),
00236          CELLTYPE_Integer_Max64 =             (CELLTYPE_Unsigned_Max64 + CELLTYPE_Signed_Max64),
00237          CELLTYPE_Float =                     (CELLTYPE_Float_32 + CELLTYPE_Float_64),
00238          CELLTYPE_Scalar =                    (CELLTYPE_Integer_Max64 + CELLTYPE_Float),
00239          CELLTYPE_Complex =                   (CELLTYPE_ComplexRI_64 + CELLTYPE_ComplexMP_64 + CELLTYPE_ComplexRI_128 + CELLTYPE_ComplexMP_128),
00240          CELLTYPE_3Cell_Color =               (CELLTYPE_X1R5G5B5_16 + CELLTYPE_X1B5G5R5_16 + CELLTYPE_RedGreenBlue_24 + CELLTYPE_BlueGreenRed_24),
00241          CELLTYPE_4Cell_Color =               (CELLTYPE_RedGreenBlueAlpha_32 + CELLTYPE_AlphaRedGreenBlue_32 + CELLTYPE_CyanMagentaYellowBlack_32 + CELLTYPE_BlackCyanMagentaYellow_32),
00242          CELLTYPE_Color =                     (CELLTYPE_3Cell_Color + CELLTYPE_4Cell_Color),
00243          CELLTYPE_ColorMapValid =             (CELLTYPE_Unsigned_4 + CELLTYPE_Unsigned_8 + CELLTYPE_Unsigned_16),
00244          CELLTYPE_HasAlphaBand =              (CELLTYPE_RedGreenBlueAlpha_32 + CELLTYPE_AlphaRedGreenBlue_32),
00245          CELLTYPE_DatabaseValid =             (CELLTYPE_Integer_Max32),
00246          CELLTYPE_All =                       (CELLTYPE_Scalar + CELLTYPE_Complex + CELLTYPE_Color)
00247          };
00248 
00249       enum PACKORDER {
00250          PACKORDER_LeastSigBit = 0,
00251          PACKORDER_MostSigBit
00252          };
00253 
00254       enum PYRAMID {
00255          PYRAMID_Default =             0x00,
00256          PYRAMID_None =                PYRAMID_Default,
00257          PYRAMID_Rebuild =             0x01, //!< Rebuild tiers even if exist
00258          PYRAMID_Average =             0x02, //!< Average raster cells instead of sampling
00259          PYRAMID_Full =                0x04, //!< Create 'full' pyramid set (always 2x2 sample steps)
00260          PYRAMID_UseParentTileSize =   0x08, //!< Use parent raster's tile size.
00261          PYRAMID_UseColorMap =         0x10, //!< Use colormap for averaging
00262          PYRAMID_Partial =             0x20  //!< Create 'partial' pyramid set (some 4x4 sample steps)
00263          };
00264          
00265       #ifndef GENERATING_DOXYGEN_OUTPUT
00266       class BANDPARMS;  //!< Forward declarations
00267       class NULLVALUE;
00268       class OBSERVER;
00269       #endif // GENERATING_DOXYGEN_OUTPUT
00270 
00271       //! Default constructor
00272       IMAGE (
00273          );
00274 
00275       //! Copy constructor
00276       IMAGE (
00277          const IMAGE& rhs
00278          );
00279 
00280       //! Destructor
00281       virtual ~IMAGE (
00282          ) = 0;
00283 
00284       //! Obtain individual image band parameters.
00285       ERRVALUE GetBandParms (
00286          INT32 BandNum,
00287          BANDPARMS& BandParms
00288          ) const { return (v_GetBandParms(BandNum, BandParms)); }
00289 
00290       //! Get CELLTYPE corresponding to COLORSPACE.
00291       //! @return CELLTYPE value or CELLTYPE_Invalid if no conversion possible.
00292       static CELLTYPE GetCellTypeFromColorSpace (
00293          COLORSPACE ColorSpace
00294          );
00295 
00296       //! Get CELLTYPE corresponding to legacy datatype and numbits
00297       //! @return CELLTYPE value or CELLTYPE_Invalid if no conversion possible.
00298       static CELLTYPE GetCellTypeFromDataTypeAndNumBits (
00299          UINT32 datatype,
00300          UINT16 numbits
00301          );
00302          
00303       //! Get Image value range according to the CELLTYPE
00304       static void GetCellTypeRange (
00305          CELLTYPE CellType,
00306          DOUBLE_RANGE& Range
00307          );
00308 
00309       //! Get the string for the IMAGE::CELLTYPE specified.
00310       //! The string is determined from the 'CellType' and the resource file
00311       static MISTRING GetCellTypeString (
00312          CELLTYPE CellType
00313          );
00314 
00315       //! Get COLORSPACE corresponding to specified cell type.
00316       //! @return COLORSPACE value or COLORSPACE_Unknown if no conversion possible.
00317       static COLORSPACE GetColorSpaceFromCellType (
00318          CELLTYPE CellType,
00319          bool haspalette = false
00320          );
00321 
00322       //! Obtain the raster cell column scale value.
00323       //! @return raster cell column scale
00324       double GetColumnScale (
00325          ) const { return (v_GetColumnScale()); }
00326          
00327       //! Get the band number to use for composite image reading and writing in one image buffer
00328       //! Only useful for images of CELLTYPE_Complex and CELLTYPE_Color
00329       //! @return Band number to read(), write() for CELLTYPE_Complex and CELLTYPE_Color images in one image buffer
00330       static INT32 GetCompositeBandNum (
00331          ) { return (-1); }
00332 
00333       //! Get DATATYPE associated with specified CELLTYPE.
00334       static DATATYPE GetDataTypeFromCellType (
00335          CELLTYPE CellType
00336          );
00337 
00338       //! Get image object referred to by 'object'
00339       //! @return Allocated instance of RVC::IMAGE object (must be 'delete'd) or 0 if error
00340       static RVC::IMAGE* GetImage (
00341          const RVC::OBJECT& object
00342          );
00343          
00344       //! Get image object referred to by 'ObjItem'
00345       //! @return Allocated instance of RVC::IMAGE object (must be 'delete'd) or 0 if error
00346       static RVC::IMAGE* GetImage (
00347          const RVC::OBJITEM& ObjItem
00348          );
00349          
00350       //! Obtain the raster cell line scale value.
00351       //! @return raster cell line scale
00352       double GetLineScale (
00353          ) const { return (v_GetLineScale()); }
00354 
00355       //! Obtain raster band null value information.
00356       ERRVALUE GetNullValue (
00357          INT32 BandNum,                   //!< Raster band number to get NULLVALUE from
00358          NULLVALUE& NullValue             //!< Current NULLVALUE to get from raster
00359          ) const { return (v_GetNullValue(BandNum, NullValue)); }
00360 
00361       //! Determine the number of bands present in the raster
00362       //! @returns number of bands
00363       INT32 GetNumBands (
00364          ) const { return (v_GetNumBands()); }
00365 
00366       //! Get number of bits per cell for specified CELLTYPE.
00367       static UINT16 GetNumBitsFromCellType (
00368          CELLTYPE CellType
00369          );
00370 
00371       //! Obtain number of columns in the raster
00372       //! @return number of columns in the raster
00373       INT32 GetNumColumns (
00374          ) const { return (v_GetNumColumns()); }
00375 
00376       //! Obtain number of lines in the raster
00377       //! @return number of lines in the raster
00378       INT32 GetNumLines (
00379          ) const { return (v_GetNumLines()); }
00380 
00381       //! Get correct OBJTYPESET for all image OBJTYPE's
00382       //! @return OBJTYPESET for all image OBJTYPE's
00383       static RVC::OBJTYPESET GetObjTypeSet (
00384          );
00385          
00386       //! Determine if null value exists for specified band.
00387       //! @return 'true' if null value used, 'false' if not.
00388       bool HasNullValue (
00389          INT32 BandNum
00390          ) const { return (v_HasNullValue(BandNum)); }
00391 
00392       //! Determine if the object type is an image object         
00393       static bool IsImage (
00394          RVC::OBJTYPE ObjType
00395          );
00396 
00397       //! Read a line of raster cells up to a certain length
00398       ERRVALUE ReadBand (
00399          INT32 Band,
00400          INT32 Line,                         //!< Raster line to read
00401          INT32 StartColumn,                  //!< Raster column to start reading on
00402          void *data,                         //!< Buffer to read into
00403          INT32 Length = 1,                   //!< Number of columns to read
00404          CONVMODE Convert = CONVMODE_None    //!< Data conversion mode
00405          ) const { return (v_ReadBand(Band, Line, StartColumn, data, Length, Convert)); }
00406 
00407       //! Read a line of raster cells up to a certain length, converting to signed 8 bit
00408       ERRVALUE ReadBand (                       //! Read a raster line, signed 8 bit
00409          INT32 Band,                         //!< Image band number to read
00410          INT32 Line,                         //!< Raster line to read
00411          INT32 StartColumn,                     //!< Raster column to start reading on
00412          INT8 *data,                         //!< Buffer to read into
00413          INT32 Length = 1                    //!< Number of columns to read
00414          ) const { return (v_ReadBand(Band, Line, StartColumn, data, Length, CONVMODE_INT8)); }
00415 
00416       //! Read a line of raster cells up to a certain length, converting to unsigned 8 bit
00417       ERRVALUE ReadBand (                       //! Read a raster line, unsigned 8 bit
00418          INT32 Band,                         //!< Image band number to read
00419          INT32 Line,                         //!< Raster line to read
00420          INT32 StartColumn,                     //!< Raster column to start reading on
00421          UINT8 *data,                        //!< Buffer to read into
00422          INT32 Length = 1                    //!< Number of columns to read
00423          ) const { return (v_ReadBand(Band, Line, StartColumn, data, Length, CONVMODE_INT8)); }
00424 
00425       //! Read a line of raster cells up to a certain length, converting to signed 16 bit
00426       ERRVALUE ReadBand (                       //! Read a raster line, signed 16 bit
00427          INT32 Band,                         //!< Image band number to read
00428          INT32 Line,                         //!< Raster line to read
00429          INT32 StartColumn,                     //!< Raster column to start reading on
00430          INT16 *data,                        //!< Buffer to read into
00431          INT32 Length = 1                    //!< Number of columns to read
00432          ) const { return (v_ReadBand(Band, Line, StartColumn, data, Length, CONVMODE_INT16)); }
00433 
00434       //! Read a line of raster cells up to a certain length, converting to unsigned 16 bit
00435       ERRVALUE ReadBand (                       //! Read a raster line, unsigned 16 bit
00436          INT32 Band,                         //!< Image band number to read
00437          INT32 Line,                         //!< Raster line to read
00438          INT32 StartColumn,                     //!< Raster column to start reading on
00439          UINT16 *data,                       //!< Buffer to read into
00440          INT32 Length = 1                    //!< Number of columns to read
00441          ) const { return (v_ReadBand(Band, Line, StartColumn, data, Length, CONVMODE_INT16)); }
00442 
00443       //! Read a line of raster cells up to a certain length, converting to signed 32 bit
00444       ERRVALUE ReadBand (                       //! Read a raster line, signed 32 bit
00445          INT32 Band,                         //!< Image band number to read
00446          INT32 Line,                         //!< Raster line to read
00447          INT32 StartColumn,                     //!< Raster column to start reading on
00448          INT32 *data,                        //!< Buffer to read into
00449          INT32 Length = 1                    //!< Number of columns to read
00450          ) const { return (v_ReadBand(Band, Line, StartColumn, data, Length, CONVMODE_INT32)); }
00451 
00452       //! Read a line of raster cells up to a certain length, converting to unsigned 32 bit
00453       ERRVALUE ReadBand (                       //! Read a raster line, unsigned 32 bit
00454          INT32 Band,                         //!< Image band number to read
00455          INT32 Line,                         //!< Raster line to read
00456          INT32 StartColumn,                     //!< Raster column to start reading on
00457          UINT32 *data,                       //!< Buffer to read into
00458          INT32 Length = 1                    //!< Number of columns to read
00459          ) const { return (v_ReadBand(Band, Line, StartColumn, data, Length, CONVMODE_INT32)); }
00460 
00461       //! Read a line of raster cells up to a certain length, converting to 32 bit float
00462       ERRVALUE ReadBand (                       //! Read a raster line, 4 byte floats
00463          INT32 Band,                         //!< Image band number to read
00464          INT32 Line,                         //!< Raster line to read
00465          INT32 StartColumn,                     //!< Raster column to start reading on
00466          float *data,                        //!< Buffer to read into
00467          INT32 Length = 1                    //!< Number of columns to read
00468          ) const { return (v_ReadBand(Band, Line, StartColumn, data, Length, CONVMODE_Float)); }
00469 
00470       //! Read a line of raster cells up to a certain length, converting to 64 bit double
00471       ERRVALUE ReadBand (                       //! Read a raster line, 8 byte doubles
00472          INT32 Band,                         //!< Image band number to read
00473          INT32 Line,                         //!< Raster line to read
00474          INT32 StartColumn,                     //!< Raster column to start reading on
00475          double *data,                       //!< Buffer to read into
00476          INT32 Length = 1                    //!< Number of columns to read
00477          ) const { return (v_ReadBand(Band, Line, StartColumn, data, Length, CONVMODE_Double)); }
00478 
00479       //! Read a line of raster cells up to a certain length
00480       ERRVALUE ReadColumnBand (
00481          INT32 Band,
00482          INT32 Line,                         //!< Raster line to read
00483          INT32 StartColumn,                  //!< Raster column to start reading on
00484          void *data,                         //!< Buffer to read into
00485          INT32 Length = 1,                   //!< Number of columns to read
00486          CONVMODE Convert = CONVMODE_None    //!< Data conversion mode
00487          ) const { return (v_ReadColumnBand(Band, Line, StartColumn, data, Length, Convert)); }
00488 
00489       //! Read a column of raster cells up to a certain length, converting to signed 8 bit
00490       ERRVALUE ReadColumnBand (                 //! Read a raster column, signed 8 bit
00491          INT32 Band,                         //!< Image band number to read
00492          INT32 Line,                         //!< Raster line to start reading on
00493          INT32 StartColumn,                     //!< Raster column to read
00494          INT8 *data,                         //!< Buffer to read into
00495          INT32 Length = 1                    //!< Number of lines to read
00496          ) const { return (v_ReadColumnBand(Band, Line, StartColumn, data, Length, CONVMODE_INT8)); }
00497 
00498       //! Read a column of raster cells up to a certain length, converting to unsigned 8 bit
00499       ERRVALUE ReadColumnBand (                 //! Read a raster column, unsigned 8 bit
00500          INT32 Band,                         //!< Image band number to read
00501          INT32 Line,                         //!< Raster line to start reading on
00502          INT32 StartColumn,                     //!< Raster column to read
00503          UINT8 *data,                        //!< Buffer to read into
00504          INT32 Length = 1                    //!< Number of lines to read
00505          ) const { return (v_ReadColumnBand(Band, Line, StartColumn, data, Length, CONVMODE_INT8)); }
00506 
00507       //! Read a column of raster cells up to a certain length, converting to signed 16 bit
00508       ERRVALUE ReadColumnBand (                 //! Read a raster column, signed 16 bit
00509          INT32 Band,                         //!< Image band number to read
00510          INT32 Line,                         //!< Raster line to start reading on
00511          INT32 StartColumn,                     //!< Raster column to read
00512          INT16 *data,                        //!< Buffer to read into
00513          INT32 Length = 1                    //!< Number of lines to read
00514          ) const { return (v_ReadColumnBand(Band, Line, StartColumn, data, Length, CONVMODE_INT16)); }
00515 
00516       //! Read a column of raster cells up to a certain length, converting to unsigned 16 bit
00517       ERRVALUE ReadColumnBand (                 //! Read a raster column, unsigned 16 bit
00518          INT32 Band,                         //!< Image band number to read
00519          INT32 Line,                         //!< Raster line to start reading on
00520          INT32 StartColumn,                     //!< Raster column to read
00521          UINT16 *data,                       //!< Buffer to read into
00522          INT32 Length = 1                    //!< Number of lines to read
00523          ) const { return (v_ReadColumnBand(Band, Line, StartColumn, data, Length, CONVMODE_INT16)); }
00524 
00525       //! Read a column of raster cells up to a certain length, converting to signed 32 bit
00526       ERRVALUE ReadColumnBand (                 //! Read a raster column, signed 32 bit
00527          INT32 Band,                         //!< Image band number to read
00528          INT32 Line,                         //!< Raster line to start reading on
00529          INT32 StartColumn,                     //!< Raster column to read
00530          INT32 *data,                        //!< Buffer to read into
00531          INT32 Length = 1                    //!< Number of lines to read
00532          ) const { return (v_ReadColumnBand(Band, Line, StartColumn, data, Length, CONVMODE_INT32)); }
00533 
00534       //! Read a column of raster cells up to a certain length, converting to unsigned 32 bit
00535       ERRVALUE ReadColumnBand (                 //! Read a raster column, unsigned 32 bit
00536          INT32 Band,                         //!< Image band number to read
00537          INT32 Line,                         //!< Raster line to start reading on
00538          INT32 StartColumn,                     //!< Raster column to read
00539          UINT32 *data,                       //!< Buffer to read into
00540          INT32 Length = 1                    //!< Number of lines to read
00541          ) const { return (v_ReadColumnBand(Band, Line, StartColumn, data, Length, CONVMODE_INT32)); }
00542 
00543       //! Read a column of raster cells up to a certain length, converting to 32 bit float
00544       ERRVALUE ReadColumnBand (                 //! Read a raster column, 4 byte floats
00545          INT32 Band,                         //!< Image band number to read
00546          INT32 Line,                         //!< Raster line to start reading on
00547          INT32 StartColumn,                     //!< Raster column to read
00548          float *data,                        //!< Buffer to read into
00549          INT32 Length = 1                    //!< Number of lines to read
00550          ) const { return (v_ReadColumnBand(Band, Line, StartColumn, data, Length, CONVMODE_Float)); }
00551 
00552       //! Read a column of raster cells up to a certain length, converting to 64 bit double
00553       ERRVALUE ReadColumnBand (                 //! Read a raster column, 8 byte doubles
00554          INT32 Band,                         //!< Image band number to read
00555          INT32 Line,                         //!< Raster line to start reading on
00556          INT32 StartColumn,                     //!< Raster column to read
00557          double *data,                       //!< Buffer to read into
00558          INT32 Length = 1                    //!< Number of lines to read
00559          ) const { return (v_ReadColumnBand(Band, Line, StartColumn, data, Length, CONVMODE_Double)); }
00560 
00561       //! Set the null value for the image
00562       //! If the 'NullValue' pointer is 'null', the image does not have a null value
00563       ERRVALUE SetNullValue (
00564          INT32 BandNum, 
00565          const NULLVALUE* NullValue                //!< If pointer is 'null', the image has no null value, if not, the image has a null value
00566          ) { return (v_SetNullValue(BandNum, NullValue)); }
00567          
00568       //! Set the image tile cache to cache the number of tiles specified
00569       ERRVALUE SetCacheSize (
00570          INT32 NumTiles                      //!< Number of tiles to set cache
00571          ) { return (v_SetCacheSize(NumTiles)); }
00572 
00573       //! Set the image tile cache to cache a number of tiles specified by the RVC::IMAGE::CACHEMODE enumeration
00574       ERRVALUE SetCacheSize (
00575          CACHEMODE CacheFlags                //!< Tile row or diagonal tile cache sizes
00576          ) { return (v_SetCacheSize(CacheFlags)); }
00577       
00578       //! Write a line of raster cells up to a certain length
00579       ERRVALUE WriteBand (
00580          INT32 Band,                         //!< Image band number to write
00581          INT32 Line,                         //!< Raster line to write
00582          INT32 StartColumn,                     //!< Raster column to start writing on
00583          void *data,                         //!< Buffer to write into
00584          INT32 Length = 1,                   //!< Number of columns to write
00585          CONVMODE Convert = CONVMODE_None       //!< Data conversion mode
00586          ) { return (v_WriteBand(Band, Line, StartColumn, data, Length, Convert)); }
00587 
00588       //! Write a line of raster cells up to a certain length, converting from signed 8 bit
00589       ERRVALUE WriteBand (                   //! Write a raster line, signed 8 bit
00590          INT32 Band,                         //!< Image band number to write
00591          INT32 Line,                         //!< Raster line to write
00592          INT32 StartColumn,                     //!< Raster column to start writing on
00593          INT8 *data,                         //!< Buffer to write from
00594          INT32 Length = 1                    //!< Number of columns to write
00595          ) { return (v_WriteBand(Band, Line, StartColumn, data, Length, CONVMODE_INT8)); }
00596 
00597       //! Write a line of raster cells up to a certain length, converting from unsigned 8 bit
00598       ERRVALUE WriteBand (                   //! Write a raster line, unsigned 8 bit
00599          INT32 Band,                         //!< Image band number to write
00600          INT32 Line,                         //!< Raster line to write
00601          INT32 StartColumn,                     //!< Raster column to start writing on
00602          UINT8 *data,                        //!< Buffer to write from
00603          INT32 Length = 1                    //!< Number of columns to write
00604          ) { return (v_WriteBand(Band, Line, StartColumn, data, Length, CONVMODE_INT8)); }
00605 
00606       //! Write a line of raster cells up to a certain length, converting from signed 16 bit
00607       ERRVALUE WriteBand (                   //! Write a raster line, signed 16 bit
00608          INT32 Band,                         //!< Image band number to write
00609          INT32 Line,                         //!< Raster line to write
00610          INT32 StartColumn,                     //!< Raster column to start writing on
00611          INT16 *data,                        //!< Buffer to write from
00612          INT32 Length = 1                    //!< Number of columns to write
00613          ) { return (v_WriteBand(Band, Line, StartColumn, data, Length, CONVMODE_INT16)); }
00614 
00615       //! Write a line of raster cells up to a certain length, converting from unsigned 16 bit
00616       ERRVALUE WriteBand (                   //! Write a raster line, unsigned 16 bit
00617          INT32 Band,                         //!< Image band number to write
00618          INT32 Line,                         //!< Raster line to write
00619          INT32 StartColumn,                     //!< Raster column to start writing on
00620          UINT16 *data,                       //!< Buffer to write from
00621          INT32 Length = 1                    //!< Number of columns to write
00622          ) { return (v_WriteBand(Band, Line, StartColumn, data, Length, CONVMODE_INT16)); }
00623 
00624       //! Write a line of raster cells up to a certain length, converting from signed 32 bit
00625       ERRVALUE WriteBand (                   //! Write a raster line, signed 32 bit
00626          INT32 Band,                         //!< Image band number to write
00627          INT32 Line,                         //!< Raster line to write
00628          INT32 StartColumn,                     //!< Raster column to start writing on
00629          INT32 *data,                        //!< Buffer to write from
00630          INT32 Length = 1                    //!< Number of columns to write
00631          ) { return (v_WriteBand(Band, Line, StartColumn, data, Length, CONVMODE_INT32)); }
00632 
00633       //! Write a line of raster cells up to a certain length, converting from unsigned 32 bit
00634       ERRVALUE WriteBand (                   //! Write a raster line, unsigned 32 bit
00635          INT32 Band,                         //!< Image band number to write
00636          INT32 Line,                         //!< Raster line to write
00637          INT32 StartColumn,                     //!< Raster column to start writing on
00638          UINT32 *data,                       //!< Buffer to write from
00639          INT32 Length = 1                    //!< Number of columns to write
00640          ) { return (v_WriteBand(Band, Line, StartColumn, data, Length, CONVMODE_INT32)); }
00641 
00642       //! Write a line of raster cells up to a certain length, converting from 32 bit float
00643       ERRVALUE WriteBand (                   //! Write a raster line, 4 byte floats
00644          INT32 Band,                         //!< Image band number to write
00645          INT32 Line,                         //!< Raster line to write
00646          INT32 StartColumn,                     //!< Raster column to start writing on
00647          float *data,                        //!< Buffer to write from
00648          INT32 Length = 1                    //!< Number of columns to write
00649          ) { return (v_WriteBand(Band, Line, StartColumn, data, Length, CONVMODE_Float)); }
00650 
00651       //! Write a line of raster cells up to a certain length, converting from 64 bit double
00652       ERRVALUE WriteBand (                   //! Write a raster line, 8 byte doubles
00653          INT32 Band,                         //!< Image band number to write
00654          INT32 Line,                         //!< Raster line to write
00655          INT32 StartColumn,                     //!< Raster column to start writing on
00656          double *data,                       //!< Buffer to write from
00657          INT32 Length = 1                    //!< Number of columns to write
00658          ) { return (v_WriteBand(Band, Line, StartColumn, data, Length, CONVMODE_Double)); }
00659 
00660    protected:
00661 
00662       static DATATYPE ConvToDATATYPE (
00663          int RvcType,
00664          UINT16 NumBits
00665          );
00666 
00667       static UINT32 ConvToRastMode (
00668          CONVMODE value
00669          );
00670          
00671       #ifndef GENERATING_DOXYGEN_OUTPUT
00672       static void ImageCallbackFunc (RVC::AnyCallbackStruct *cb, void *data);
00673       #endif // GENERATING_DOXYGEN_OUTPUT
00674 
00675    private:
00676       #ifndef GENERATING_DOXYGEN_OUTPUT
00677    
00678       virtual ERRVALUE v_GetBandParms (INT32 BandNum, BANDPARMS& BandParms) const = 0;
00679       virtual double v_GetColumnScale () const = 0;
00680       virtual double v_GetLineScale () const = 0;
00681       virtual ERRVALUE v_GetNullValue (INT32 BandNum, NULLVALUE& NullValue) const = 0;
00682       virtual INT32 v_GetNumBands () const = 0;
00683       virtual INT32 v_GetNumColumns () const = 0;
00684       virtual INT32 v_GetNumLines () const = 0;
00685       virtual bool v_HasNullValue (INT32 BandNum) const = 0;
00686       virtual ERRVALUE v_ReadBand (INT32 Band, INT32 Line, INT32 StartColumn, void *data, INT32 Length, CONVMODE Convert) const = 0;
00687       virtual ERRVALUE v_ReadColumnBand (INT32 Band, INT32 Line, INT32 StartColumn, void *data, INT32 Length, CONVMODE Convert) const = 0;
00688       virtual ERRVALUE v_SetCacheSize (INT32 NumTiles) = 0;
00689       virtual ERRVALUE v_SetCacheSize (CACHEMODE CacheFlags) = 0;
00690       virtual ERRVALUE v_SetNullValue (INT32 BandNum, const NULLVALUE* NullValue) = 0;
00691       virtual ERRVALUE v_WriteBand (INT32 Band, INT32 Line, INT32 StartColumn, void *data, INT32 Length, CONVMODE Convert) = 0;
00692       #endif // GENERATING_DOXYGEN_OUTPUT
00693 
00694    public:
00695       //! Temporary static method to convert IMAGE::DATATYPE's to legacy RVCTYPE flags
00696       //! @return: RVCTYPE_ flag
00697       static UINT16 ConvToRVCTYPE (
00698          DATATYPE type,
00699          UINT16 NumBits
00700          );
00701 
00702    };
00703 
00704 DEFINE_ENUM_OP_BITWISE(IMAGE::CELLTYPE)
00705 DEFINE_ENUM_OP_BITWISE(IMAGE::PYRAMID);
00706 
00707 //! Class to represent and manage band specific information.
00708 class IMAGE::BANDPARMS {
00709    public:
00710        
00711       //! Default constructor
00712       BANDPARMS (
00713          ) :
00714          m_CellType(CELLTYPE_Invalid),
00715          m_PackOrder(PACKORDER_MostSigBit)
00716          {}
00717 
00718       //! Destructor
00719       ~BANDPARMS (
00720          ) {}
00721 
00722       //! Obtain the number of bits in this band.
00723       //! @return Number of bits.
00724       UINT16 GetNumBits (
00725          ) const { return (IMAGE::GetNumBitsFromCellType(m_CellType)); }
00726 
00727       //! Obtain the celltype of the image band
00728       //! @return Celltype of the image band
00729       CELLTYPE GetCellType (
00730          ) const { return (m_CellType); }
00731 
00732       //! Obtain the datatype of the image band
00733       //! @return Datatype of the image band
00734       DATATYPE GetDataType (
00735          ) const { return (IMAGE::GetDataTypeFromCellType(m_CellType)); }
00736 
00737       //! Obtain the packing order of the band
00738       //! @return Packing order
00739       PACKORDER GetPackOrder (
00740          ) const { return (m_PackOrder); }
00741 
00742       //! Set image band cell type.
00743       void SetCellType (
00744          CELLTYPE CellType
00745          ) { m_CellType = CellType; }
00746 
00747       //! Set the image band name.
00748       void SetName (
00749          const RVCOBJECTNAME& name
00750          ) { m_Name = name; }
00751 
00752       //! Set the image band name.
00753       void SetName (
00754          const char *name
00755          ) { m_Name.Assign(name); }
00756 
00757       //! Set the image band packing order
00758       void SetPackOrder (
00759          PACKORDER PackOrder
00760          ) { m_PackOrder = PackOrder; }
00761 
00762    private:
00763       #ifndef GENERATING_DOXYGEN_OUTPUT
00764       OBJECTNAME m_Name;
00765       CELLTYPE m_CellType;
00766       PACKORDER m_PackOrder;
00767       #endif // GENERATING_DOXYGEN_OUTPUT
00768    }; // End BANDPARMS.
00769 
00770 
00771 //! Container for image null value.
00772 class IMAGE::NULLVALUE {
00773    public:
00774 
00775       //! Default constructor.
00776       NULLVALUE (
00777          ): m_CellType(CELLTYPE_Invalid)
00778          {
00779          SetDefault();
00780          }
00781 
00782       //! Construct for specified cell type and initialize to default.
00783       explicit NULLVALUE (
00784          CELLTYPE CellType
00785          ): m_CellType(CellType)
00786          {
00787          SetDefault();
00788          }
00789 
00790       //! Obtain raster null value as ANYRASTVALUE.
00791       void GetValue (
00792          ANYRASTVALUE& value
00793          ) const;
00794 
00795       //! Get null value as INT8.
00796       //! @return Error if value cannot be converted without truncation.
00797       ERRVALUE GetValue (
00798          INT8& value
00799          ) const;
00800 
00801       //! Get null value as UINT8.
00802       //! @return Error if value cannot be converted without truncation.
00803       ERRVALUE GetValue (
00804          UINT8& value
00805          ) const;
00806 
00807       //! Get null value as INT16.
00808       //! @return Error if value cannot be converted without truncation.
00809       ERRVALUE GetValue (
00810          INT16& value
00811          ) const;
00812 
00813       //! Get null value as UINT16, suitable for 16-bit RGB also.
00814       //! @return Error if value cannot be converted without truncation.
00815       ERRVALUE GetValue (
00816          UINT16& value
00817          ) const;
00818 
00819       //! Get null value as INT32.
00820       //! @return Error if value cannot be converted without truncation.
00821       ERRVALUE GetValue (
00822          INT32& value
00823          ) const;
00824 
00825       //! Get null value as UINT32.
00826       //! @return Error if value cannot be converted without truncation.
00827       ERRVALUE GetValue (
00828          UINT32& value
00829          ) const;
00830 
00831       //! Get null value as float.
00832       //! @return Error if value cannot be converted without truncation.
00833       ERRVALUE GetValue (
00834          float& value
00835          ) const;
00836 
00837       //! Get null value as double.
00838       //! @return Error if value cannot be converted without truncation.
00839       ERRVALUE GetValue (
00840          double& value
00841          ) const;
00842 
00843       //! Get null value as FCOMPLEXRI.
00844       //! @return Error if value cannot be converted without truncation.
00845       ERRVALUE GetValue (
00846          FCOMPLEXRI& value
00847          ) const;
00848 
00849       //! Get null value as FCOMPLEXMP.
00850       //! @return Error if value cannot be converted without truncation.
00851       ERRVALUE GetValue (
00852          FCOMPLEXMP& value
00853          ) const;
00854 
00855       //! Get null value as DCOMPLEXRI.
00856       //! @return Error if value cannot be converted without truncation.
00857       ERRVALUE GetValue (
00858          DCOMPLEXRI& value
00859          ) const;
00860 
00861       //! Get null value as DCOMPLEXMP.
00862       //! @return Error if value cannot be converted without truncation.
00863       ERRVALUE GetValue (
00864          DCOMPLEXMP& value
00865          ) const;
00866 
00867       //! Set cell type for null value.
00868       //! This will also set the null value to the default for the specified cell type.
00869       void SetCellType (
00870          CELLTYPE CellType
00871          ) { m_CellType = CellType; SetDefault(); }
00872 
00873       //! Set default null value for current cell type.
00874       void SetDefault (
00875          );
00876 
00877       //! Set cell type and value from ANYRASTVALUE.
00878       void SetValue (
00879          CELLTYPE CellType,
00880          const ANYRASTVALUE& value
00881          );
00882 
00883       //! Set value from signed integer.
00884       //! @return Error if out of range for current cell type.
00885       ERRVALUE SetValue (
00886          int value
00887          );
00888 
00889       //! Set value from unsigned integer.
00890       //! @return Error if out of range for current cell type.
00891       ERRVALUE SetValue (
00892          unsigned int value
00893          );
00894 
00895       //! Set value from float/double.
00896       //! @return Error if out of range for current cell type.
00897       ERRVALUE SetValue (
00898          double value
00899          );
00900 
00901       //! Set value from FCOMPLEXRI.
00902       //! @return Error if out of range for current cell type.
00903       ERRVALUE SetValue (
00904          const FCOMPLEXRI& value
00905          );
00906 
00907       //! Set value from FCOMPLEXMP.
00908       //! @return Error if out of range for current cell type.
00909       ERRVALUE SetValue (
00910          const FCOMPLEXMP& value
00911          );
00912 
00913       //! Set value from DCOMPLEXRI.
00914       //! @return Error if out of range for current cell type.
00915       ERRVALUE SetValue (
00916          const DCOMPLEXRI& value
00917          );
00918 
00919       //! Set value from DCOMPLEXMP.
00920       //! @return Error if out of range for current cell type.
00921       ERRVALUE SetValue (
00922          const DCOMPLEXMP& value
00923          );
00924 
00925    private:
00926       #ifndef GENERATING_DOXYGEN_OUTPUT
00927       double m_ValueD;
00928       double m_ValueD2;
00929       UINT8 m_ValueRGB[4];
00930       CELLTYPE m_CellType;
00931 
00932       bool IsColor () const;
00933       bool IsComplex () const;
00934       bool IsInt () const;
00935       #endif // GENERATING_DOXYGEN_OUTPUT
00936 
00937    }; // End NULLVALUE
00938 
00939 
00940 //! OBSERVER class for RVC::IMAGE objects.
00941 class IMAGE::OBSERVER : public RVC::OBJECTOBSERVER {
00942    public:  
00943       enum TYPE {
00944          TYPE_NullValueChange = 0x00000111
00945          };
00946 
00947       explicit OBSERVER (
00948          RVC::IMAGE& object
00949          ) : OBJECTOBSERVER(object) {}
00950          
00951       virtual ~OBSERVER (
00952          ) {}
00953          
00954    private:
00955       //! Called when the image object null value settings have changed
00956       virtual void v_OnNullValueChanged (
00957          const ANYRASTVALUE& NullValue,
00958          bool IsNullUsed
00959          ) { return; }
00960 
00961       #ifndef GENERATING_DOXYGEN_OUTPUT
00962       virtual void OnNotifyRaw (UINT32 reason, void *data);
00963       #endif // GENERATING_DOXYGEN_OUTPUT
00964    };
00965 
00966 }     //! End of RVC namespace
00967 
00968 #endif      //!< INC_RVC_IMAGE_H

Generated on Tue Dec 14 13:18:43 2004 for TNTsdk by  doxygen 1.3.8-20040913