/usr/include/ossim/imaging/ossimGeneralRasterInfo.h is in libossim-dev 1.8.16-3+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | //*******************************************************************
// Copyright (C) 2000 ImageLinks Inc.
//
// License: LGPL
//
// See LICENSE.txt file in the top level directory for more details.
//
// Author: David Burken
//
// Description:
//
// Contains class declaration for ossimGeneralRasterInfo
//*******************************************************************
// $Id: ossimGeneralRasterInfo.h 22197 2013-03-12 02:00:55Z dburken $
#ifndef ossimGeneralRasterInfo_HEADER
#define ossimGeneralRasterInfo_HEADER 1
#include <ossim/base/ossimObject.h>
#include <ossim/base/ossimCommon.h>
#include <ossim/base/ossimConstants.h>
#include <ossim/base/ossimDrect.h>
#include <ossim/base/ossimErrorContext.h>
#include <ossim/base/ossimFilename.h>
#include <ossim/base/ossimIrect.h>
#include <ossim/imaging/ossimImageMetaData.h>
#include <vector>
//---
// Forward class declarations.
//---
class ossimEnviHeader;
class ossimKeywordlist;
/**
* @class ossimGeneralRasterInfo
*
*/
class OSSIMDLLEXPORT ossimGeneralRasterInfo : public ossimObject
{
public:
enum ossimFillMode
{
NONE,
ZEROES_TO_MIN,
ZEROES_TO_NULL_EDGES_ONLY
};
enum
{
UNKNOWN = -1
};
/* @brief default constructor */
ossimGeneralRasterInfo();
ossimGeneralRasterInfo(const std::vector<ossimFilename>& imageFileList,
ossimScalarType pixelType,
ossimInterleaveType il_type,
ossim_int32 numberOfBands,
ossim_int32 lines,
ossim_int32 samples,
ossim_int32 headerSize,
ossimFillMode nullsMode,
ossim_int32 pixelsToChop);
ossimGeneralRasterInfo(const ossimKeywordlist& kwl, const char* prefix=0);
/* @brief copy constructor */
ossimGeneralRasterInfo( const ossimGeneralRasterInfo& obj );
/** @brief Assignment operator=. */
const ossimGeneralRasterInfo& operator=( const ossimGeneralRasterInfo& rhs );
virtual ~ossimGeneralRasterInfo ();
/**
* Zero based rectangle of the valid image.
*/
const ossimIrect& imageRect() const;
/**
* Returns the rectangle of where the image is within the raster file.
* In most cases this will be the same as the rawImageRect. (zero based)
*/
const ossimIrect& validImageRect() const;
/**
* Zero based rectangle of the raw image.
*/
const ossimIrect& rawImageRect() const;
/**
* Returns the offset of this image's origin to a full-image's origin, in
* the case where this image is a sub-image of a larger full-image.
*/
const ossimIpt& subImageOffset() const;
/**
* Returns the size of header in bytes.
*/
ossim_int32 headerSize() const;
/**
* Returns the fill mode. This is used to flip values on ingest.
* Valid Mode Enumerations:
* - 0 Do nothing to the pixels on ingest.
* - 1 Flip all zeroes to the minimum pixel value.
* - 2 Flip zeroes within the image line to minimum pixel value.
* This is used by edge walking code.
*/
ossim_uint32 fillToNullsMode() const;
/**
* Sets theSetNullsMode.
*/
void setFillToNullsMode(ossim_uint32 mode);
/**
* @brief Number of bands. Inlined below.
* @return Number of bands from theMetaData class member cast to an int32.
*/
inline ossim_int32 numberOfBands() const;
/**
* @brief Bytes per pixel. Inlined below.
* @return Bytes per pixel from theMetaData class member cast to an int32.
*/
inline ossim_int32 bytesPerPixel() const;
/**
* Returns the number of pixels from the edge of a line
* to set to the fill value. This can be used to eliminate
* resampling error on the edge of an image and still keep
* the image demensions relative to the geometry file.
*/
ossim_int32 pixelsToChop() const;
/**
* Enumerated in InterleaveTypeLUT. Should be either bip,
* bil or bsq. Defaulted to bip.
*/
ossimInterleaveType interleaveType() const;
/**
* Returns the number of lines within "theValidImageRect".
*/
inline ossim_int32 validLines() const;
/**
* Returns the number of lines within "theRawImageRect".
*/
inline ossim_int32 rawLines() const;
/**
* Returns the number of bytes in a raw line.
*/
inline ossim_int32 bytesPerRawLine() const;
/**
* Returns the number of bytes in a valid line.
*/
inline ossim_int32 bytesPerValidLine() const;
/**
* Returns the number of samples within "theValidImageRect".
*/
inline ossim_int32 validSamples() const;
/**
* Returns the number of samples within "theRawImageRect".
*/
inline ossim_int32 rawSamples() const;
/**
* Returns the offset in bytes to the first valid sample in the image.
*/
inline std::streamoff offsetToFirstValidSample() const;
const std::vector<ossimFilename>& getImageFileList() const;
void setImageFileList(const std::vector<ossimFilename>& list);
/**
* @brief Sets the image file list to file. Performs a clear, prior to
* setting.
* @param file Image file.
*/
void setImageFile(const ossimFilename& file);
void setHeaderSize(ossim_int32 headerSize);
void setInterleaveType(ossimInterleaveType il_type);
virtual std::ostream& print(std::ostream& out) const;
void setImageRect(const ossimIrect& imageRect);
void setValidImageRect(const ossimIrect &imageRect);
void setRawImageRect(const ossimIrect &imageRect);
void setSubImageOffset(const ossimIpt& d);
ossimByteOrder getImageDataByteOrder() const;
void setImageDataByteOrder(ossimByteOrder byteOrder);
/**
* Method to save the state of an object to a keyword list.
* Return true if ok or false on error.
*/
virtual bool saveState(ossimKeywordlist& kwl,
const char* prefix=0) const;
/**
* Method to the load (recreate) the state of an object from a keyword
* list. Return true if ok or false on error.
*/
virtual bool loadState(const ossimKeywordlist& kwl,
const char* prefix=0);
/**
* @brief Takes image file and attempts to derive/find header file to
* parse for general raster data, i.e. lines, samples, bands and so on.
* @param image file.
* @return true on success, false on error.
*/
bool open( const ossimFilename& imageFile );
/** @return Const reference to theMetaData class member. */
inline const ossimImageMetaData& getImageMetaData() const;
/** @return Reference to theMetaData class member. */
inline ossimImageMetaData& getImageMetaData();
/**
* @brief Initialize from envi header file.
* @param enviHeader
* @return true on success, false on error.
*/
bool initializeFromEnviHdr( const ossimEnviHeader& enviHdr );
private:
/**
* @brief Initialize from header file.
* @param headerFile
* @return true on success, false on error.
*/
bool initializeFromHdr( const ossimFilename& imageFile,
const ossimFilename& headerFile );
/**
* @brief Initialize from envi header file.
* @param headerFile
* @return true on success, false on error.
*/
bool initializeFromEnviHdr( const ossimFilename& headerFile );
/**
* @brief Initialize from omd file.
* @param file
* @return true on success, false on error.
*/
bool initializeFromXml( const ossimFilename& imageFile,
const ossimFilename& headerFile );
/**
* @brief Private method to get bits per pixel from file size,
* lines, samples and bands. Method created to avoid duplicate code
* in "initizeFrom" methods.
*
* This assumes that "theRawImageRect" and "theNumberOfBands" has been
* set.
*
* @param imageFile This image file.
* @param Calculated bits per pixel.
* @return bits per pixel or 0 on error.
*/
ossim_int32 getBitsPerPixel( const ossimFilename& imageFile ) const;
/** @brief Clears data members. */
void clear();
ossimImageMetaData theMetaData;
std::vector<ossimFilename> theImageFileList;
ossimInterleaveType theInterleaveType;
/**
* The zero based rectangle of the entire image not including any header.
*/
ossimIrect theRawImageRect;
/**
* The rectangle representing where the valid part of the image lies
* within "theRawImageRect".
*/
ossimIrect theValidImageRect;
/**
* The valid image rectangle normalized to be zero based.
*/
ossimIrect theImageRect;
/**
* The offset from the full-image origin to this image's origin
*/
ossimIpt theSubImageOffset;
/**
* Size of header in bytes.
*/
ossim_int32 theHeaderSize;
/**
* Mode of how to handle pixels on import.
* 0 = Do nothing the pixels.
* 1 = Set any zeroes to min value of radiometry.
* 2 = Set zeroes on line edges only to nulls; any other zeroes are
* set to min value of radiometry.
*/
ossimFillMode theSetNullsMode;
/**
* Amount of pixels to chop for each line edge.
*/
ossim_int32 thePixelsToChop;
/**
* The byte order the image data is stored in.
*/
ossimByteOrder theImageDataByteOrder;
};
//---
// Inlines:
//
// These methods are used throughout raster read/write code; hence, inlines.
// Note that most of these are used in calculating std::streamoff which is
// a signed 64 bit integer on most machines; hence, the cast to an int from
// an unsigned int for convenience.
//---
inline const ossimImageMetaData& ossimGeneralRasterInfo::getImageMetaData() const
{
return theMetaData;
}
inline ossimImageMetaData& ossimGeneralRasterInfo::getImageMetaData()
{
return theMetaData;
}
inline ossim_int32 ossimGeneralRasterInfo::numberOfBands() const
{
return static_cast<ossim_int32>( theMetaData.getNumberOfBands() );
}
inline ossim_int32 ossimGeneralRasterInfo::bytesPerPixel() const
{
return static_cast<ossim_int32>( theMetaData.getBytesPerPixel() );
}
inline ossim_int32 ossimGeneralRasterInfo::validLines() const
{
return static_cast<ossim_int32>(theValidImageRect.height());
}
inline ossim_int32 ossimGeneralRasterInfo::rawLines() const
{
return static_cast<ossim_int32>(theRawImageRect.height());
}
inline ossim_int32 ossimGeneralRasterInfo::bytesPerRawLine() const
{
if (interleaveType() == OSSIM_BIP)
{
return rawSamples() * bytesPerPixel() * numberOfBands();
}
else
{
return rawSamples() * bytesPerPixel();
}
}
inline ossim_int32 ossimGeneralRasterInfo::bytesPerValidLine() const
{
if (interleaveType() == OSSIM_BIP)
{
return validSamples() * bytesPerPixel() * numberOfBands();
}
else
{
return validSamples() * bytesPerPixel();
}
}
inline ossim_int32 ossimGeneralRasterInfo::validSamples() const
{
return static_cast<ossim_int32>(theValidImageRect.width());
}
inline ossim_int32 ossimGeneralRasterInfo::rawSamples() const
{
return static_cast<ossim_int32>(theRawImageRect.width());
}
inline std::streamoff ossimGeneralRasterInfo::offsetToFirstValidSample() const
{
if (interleaveType() == OSSIM_BIP)
{
return headerSize() +
( bytesPerRawLine() * validImageRect().ul().y ) +
( validImageRect().ul().x * numberOfBands() * bytesPerPixel() );
}
else if (interleaveType() == OSSIM_BIL)
{
return headerSize() +
( bytesPerRawLine() * validImageRect().ul().y * numberOfBands() ) +
( validImageRect().ul().x * bytesPerPixel() );
}
else // BSQ
{
return headerSize() +
( bytesPerRawLine() * validImageRect().ul().y ) +
( validImageRect().ul().x * bytesPerPixel() );
}
}
#endif
|