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

Generated on Thu Aug 12 06:19:41 2004 for TNTsdk by doxygen 1.3.4-20031026