memdataset.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /******************************************************************************
  2. * $Id: memdataset.h 28899 2015-04-14 09:27:00Z rouault $
  3. *
  4. * Project: Memory Array Translator
  5. * Purpose: Declaration of MEMDataset, and MEMRasterBand.
  6. * Author: Frank Warmerdam, warmerdam@pobox.com
  7. *
  8. ******************************************************************************
  9. * Copyright (c) 2000, Frank Warmerdam
  10. *
  11. * Permission is hereby granted, free of charge, to any person obtaining a
  12. * copy of this software and associated documentation files (the "Software"),
  13. * to deal in the Software without restriction, including without limitation
  14. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  15. * and/or sell copies of the Software, and to permit persons to whom the
  16. * Software is furnished to do so, subject to the following conditions:
  17. *
  18. * The above copyright notice and this permission notice shall be included
  19. * in all copies or substantial portions of the Software.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  22. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  24. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  26. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  27. * DEALINGS IN THE SOFTWARE.
  28. ****************************************************************************/
  29. #ifndef MEMDATASET_H_INCLUDED
  30. #define MEMDATASET_H_INCLUDED
  31. #include "gdal_pam.h"
  32. #include "gdal_priv.h"
  33. CPL_C_START
  34. void GDALRegister_MEM(void);
  35. /* Caution: if changing this prototype, also change in swig/include/gdal_python.i
  36. where it is redefined */
  37. GDALRasterBandH CPL_DLL MEMCreateRasterBand( GDALDataset *, int, GByte *,
  38. GDALDataType, int, int, int );
  39. CPL_C_END
  40. /************************************************************************/
  41. /* MEMDataset */
  42. /************************************************************************/
  43. class MEMRasterBand;
  44. class CPL_DLL MEMDataset : public GDALDataset
  45. {
  46. int bGeoTransformSet;
  47. double adfGeoTransform[6];
  48. char *pszProjection;
  49. int nGCPCount;
  50. GDAL_GCP *pasGCPs;
  51. CPLString osGCPProjection;
  52. public:
  53. MEMDataset();
  54. virtual ~MEMDataset();
  55. virtual const char *GetProjectionRef(void);
  56. virtual CPLErr SetProjection( const char * );
  57. virtual CPLErr GetGeoTransform( double * );
  58. virtual CPLErr SetGeoTransform( double * );
  59. virtual void *GetInternalHandle( const char * );
  60. virtual int GetGCPCount();
  61. virtual const char *GetGCPProjection();
  62. virtual const GDAL_GCP *GetGCPs();
  63. virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
  64. const char *pszGCPProjection );
  65. virtual CPLErr AddBand( GDALDataType eType,
  66. char **papszOptions=NULL );
  67. virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
  68. int nXOff, int nYOff, int nXSize, int nYSize,
  69. void * pData, int nBufXSize, int nBufYSize,
  70. GDALDataType eBufType,
  71. int nBandCount, int *panBandMap,
  72. GSpacing nPixelSpaceBuf,
  73. GSpacing nLineSpaceBuf,
  74. GSpacing nBandSpaceBuf,
  75. GDALRasterIOExtraArg* psExtraArg);
  76. static GDALDataset *Open( GDALOpenInfo * );
  77. static GDALDataset *Create( const char * pszFilename,
  78. int nXSize, int nYSize, int nBands,
  79. GDALDataType eType, char ** papszParmList );
  80. };
  81. /************************************************************************/
  82. /* MEMRasterBand */
  83. /************************************************************************/
  84. class CPL_DLL MEMRasterBand : public GDALPamRasterBand
  85. {
  86. protected:
  87. friend class MEMDataset;
  88. GByte *pabyData;
  89. GSpacing nPixelOffset;
  90. GSpacing nLineOffset;
  91. int bOwnData;
  92. int bNoDataSet;
  93. double dfNoData;
  94. GDALColorTable *poColorTable;
  95. GDALColorInterp eColorInterp;
  96. char *pszUnitType;
  97. char **papszCategoryNames;
  98. double dfOffset;
  99. double dfScale;
  100. CPLXMLNode *psSavedHistograms;
  101. public:
  102. MEMRasterBand( GDALDataset *poDS, int nBand,
  103. GByte *pabyData, GDALDataType eType,
  104. GSpacing nPixelOffset, GSpacing nLineOffset,
  105. int bAssumeOwnership, const char * pszPixelType = NULL);
  106. virtual ~MEMRasterBand();
  107. virtual CPLErr IReadBlock( int, int, void * );
  108. virtual CPLErr IWriteBlock( int, int, void * );
  109. virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
  110. int nXOff, int nYOff, int nXSize, int nYSize,
  111. void * pData, int nBufXSize, int nBufYSize,
  112. GDALDataType eBufType,
  113. GSpacing nPixelSpaceBuf,
  114. GSpacing nLineSpaceBuf,
  115. GDALRasterIOExtraArg* psExtraArg );
  116. virtual double GetNoDataValue( int *pbSuccess = NULL );
  117. virtual CPLErr SetNoDataValue( double );
  118. virtual GDALColorInterp GetColorInterpretation();
  119. virtual GDALColorTable *GetColorTable();
  120. virtual CPLErr SetColorTable( GDALColorTable * );
  121. virtual CPLErr SetColorInterpretation( GDALColorInterp );
  122. virtual const char *GetUnitType();
  123. CPLErr SetUnitType( const char * );
  124. virtual char **GetCategoryNames();
  125. virtual CPLErr SetCategoryNames( char ** );
  126. virtual double GetOffset( int *pbSuccess = NULL );
  127. CPLErr SetOffset( double );
  128. virtual double GetScale( int *pbSuccess = NULL );
  129. CPLErr SetScale( double );
  130. virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
  131. int nBuckets, GUIntBig *panHistogram );
  132. virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
  133. int *pnBuckets, GUIntBig ** ppanHistogram,
  134. int bForce,
  135. GDALProgressFunc, void *pProgressData);
  136. // allow access to MEM driver's private internal memory buffer
  137. GByte *GetData(void) const {return(pabyData);}
  138. };
  139. #endif /* ndef MEMDATASET_H_INCLUDED */