OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimMemoryImageSource.cpp
Go to the documentation of this file.
1 //*******************************************************************.
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: Garrett Potts
8 //
9 //*************************************************************************
10 //
14 RTTI_DEF1(ossimMemoryImageSource, "ossimMemoryImageSource", ossimImageSource);
15 
17  :ossimImageSource(0, 0, 1, true, false)
18 {
20 }
21 
23 {
24  m_image = image.get();
25  if(m_image.valid())
26  {
28  }
29  else
30  {
32  }
33  m_result = 0;
34 }
35 
37  ossim_uint32 numberOfBands,
38  ossim_uint32 width,
39  ossim_uint32 height)
40 {
41  m_image = new ossimImageData(0,
42  scalarType,
43  numberOfBands,
44  width,
45  height);
47 
49  m_result = 0;
50 }
51 
53  ossim_uint32 uly,
54  ossim_uint32 width,
55  ossim_uint32 height)
56 {
57  if(m_image.valid())
58  {
60  ulx + (width-1),
61  uly + (height-1)));
63  }
64 }
65 
67 {
68  if(m_image.valid())
69  {
70  return m_image->getNumberOfBands();
71  }
72  return 0;;
73 }
74 
76 {
77  return getNumberOfInputBands();
78 }
79 
81 {
82  if(m_image.valid())
83  {
84  return m_image->getScalarType();
85  }
86 
88 }
89 
91 {
92  if(m_image.valid())
93  {
94  if(band < getNumberOfInputBands())
95  {
96  return m_image->getNullPix(band);
97  }
98  }
100 }
101 
103 {
104  if(m_image.valid())
105  {
106  if(band < getNumberOfInputBands())
107  {
108  return m_image->getMinPix(band);
109  }
110  }
112 }
113 
115 {
116  if(m_image.valid())
117  {
118  if(band < getNumberOfInputBands())
119  {
120  return m_image->getMaxPix(band);
121  }
122  }
124 }
125 
127 {
128  if(resLevel == 0)
129  {
130  if(m_image.valid())
131  {
132  return m_boundingRect;
133  }
134  }
135 
136  return ossimImageSource::getBoundingRect(resLevel);
137 }
138 
140  ossim_uint32 /* resLevel */)
141 {
142  if(!isSourceEnabled()||!m_image.valid()||m_boundingRect.hasNans()) return 0;
143  if(!m_result.valid())
144  {
146  m_result->initialize();
147  }
148 
150  m_result->makeBlank();
151  ossimIrect clampRect = m_image->getImageRectangle().clipToRect(rect);
152 
155  OSSIM_BSQ);
156 
157  m_result->validate();
158  return m_result;
159 }
160 
161 
163  const ossimConnectableObject* /* object */)const
164 {
165  return false;
166 }
167 
169 {
170  m_result = 0;
171 }
172 
174 {
175  return 1;
176 }
177 
179  ossimDpt& result) const
180 {
181  if (resLevel == 0)
182  {
183  result.x = 1.0;
184  result.y = 1.0;
185  }
186  else
187  {
188  result.x = 1.0 / (1<<resLevel);
189  result.y = result.x;
190  }
191 }
192 
193 void ossimMemoryImageSource::getDecimationFactors(std::vector<ossimDpt>& decimations)const
194 {
195  decimations.push_back(ossimDpt(1.0,1.0));
196 }
197 
198 
199 bool ossimMemoryImageSource::saveState(ossimKeywordlist& kwl, const char* prefix)const
200 {
201 
202  ossimString imagePrefix = ossimString(prefix) + "image.";
203  ossimString geomPrefix = ossimString(prefix) + "geom.";
204  if(m_image.valid())
205  {
206  m_image->saveState(kwl, imagePrefix);
207  }
208  if(m_geometry.valid())
209  {
210  m_geometry->saveState(kwl, geomPrefix);
211  }
212  return ossimImageSource::saveState(kwl, prefix);
213 }
214 
215 bool ossimMemoryImageSource::loadState(const ossimKeywordlist& kwl, const char* prefix)
216 {
217  bool returnResult = ossimImageSource::loadState(kwl, prefix);
218  m_geometry = 0;
219  if(returnResult)
220  {
221  ossimString imagePrefix = ossimString(prefix) + "image.";
222  ossimString geomPrefix = ossimString(prefix) + "geom.";
223 
224  ossimString type = kwl.find(imagePrefix, "type");
225  if(!type.empty())
226  {
227  m_image = new ossimImageData();
228  returnResult = m_image->loadState(kwl, imagePrefix.c_str());
229  m_image->initialize();
231  }
232 
233  if(returnResult)
234  {
235  type = kwl.find(geomPrefix, "type");
236  if(!type.empty())
237  {
239  returnResult = m_geometry->loadState(kwl, geomPrefix.c_str());
240  }
241  }
242  }
243  m_result = 0;
244  return returnResult;
245 }
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
virtual bool canConnectMyInputTo(ossim_int32 myInputIndex, const ossimConnectableObject *object) const
required to be overriden by derived classes
virtual const ossim_float64 * getMaxPix() const
void setRect(ossim_uint32 ulx, ossim_uint32 uly, ossim_uint32 width, ossim_uint32 height)
virtual ossim_uint32 getNumberOfBands() const
virtual void setImageRectangle(const ossimIrect &rect)
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Attempts to initialize a transform and a projection given the KWL.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
const char * find(const char *key) const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
double y
Definition: ossimDpt.h:165
ossim_uint32 height() const
Definition: ossimIrect.h:487
void setImage(ossimRefPtr< ossimImageData > image)
ossimRefPtr< ossimImageData > m_image
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
ossimRefPtr< ossimImageGeometry > m_geometry
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
virtual void initialize()
Initialize the data buffer.
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0)
virtual ossimDataObjectStatus validate() const
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
loadState is here so one can construct a memory source as a blank tile.
virtual ossimIrect getImageRectangle() const
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
ossim_uint32 width() const
Definition: ossimIrect.h:500
virtual ossim_uint32 getNumberOfInputBands() const
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
ossimScalarType
virtual ossim_uint32 getNumberOfDecimationLevels() const
Will return the number of resolution levels.
RTTI_DEF1(ossimMemoryImageSource, "ossimMemoryImageSource", ossimImageSource)
virtual const ossim_float64 * getMinPix() const
ossimRefPtr< ossimImageData > m_result
virtual ossimScalarType getScalarType() const
virtual void makeBlank()
Initializes data to null pixel values.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
save state is not implemented for this source and only passes to the base.
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
virtual void getDecimationFactor(ossim_uint32 resLevel, ossimDpt &result) const
Will return the decimation factor for the given resolution level.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
void makeNan()
Definition: ossimIrect.h:329
virtual const void * getBuf() const
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
double x
Definition: ossimDpt.h:164
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
bool empty() const
Definition: ossimString.h:411
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
bool hasNans() const
Definition: ossimIrect.h:337
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the transform (if any) and projection (if any) states to the KWL.
virtual void getDecimationFactors(std::vector< ossimDpt > &decimations) const
Will return an array of all decimations for each resolution level.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
int ossim_int32