OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Private Attributes | Friends | List of all members
ossimRpfColorGrayscaleTable Class Reference

#include <ossimRpfColorGrayscaleTable.h>

Public Member Functions

 ossimRpfColorGrayscaleTable ()
 
 ossimRpfColorGrayscaleTable (const ossimRpfColorGrayscaleTable &rhs)
 
virtual ~ossimRpfColorGrayscaleTable ()
 
ossimErrorCode parseStream (std::istream &in, ossimByteOrder byteOrder)
 
void setTableData (unsigned short id, unsigned long numberOfElements)
 
const ossimRpfColorGrayscaleTableoperator= (const ossimRpfColorGrayscaleTable &)
 
const unsigned char * getData () const
 
const unsigned char * getStartOfData (unsigned long entry) const
 
unsigned short getTableId () const
 
unsigned long getNumberOfElements () const
 

Private Attributes

unsigned long theNumberOfElements
 
unsigned long theTotalNumberOfBytes
 
unsigned short theTableId
 
unsigned char * theData
 

Friends

std::ostream & operator<< (std::ostream &out, const ossimRpfColorGrayscaleTable &data)
 

Detailed Description

Definition at line 8 of file ossimRpfColorGrayscaleTable.h.

Constructor & Destructor Documentation

◆ ossimRpfColorGrayscaleTable() [1/2]

ossimRpfColorGrayscaleTable::ossimRpfColorGrayscaleTable ( )

◆ ossimRpfColorGrayscaleTable() [2/2]

ossimRpfColorGrayscaleTable::ossimRpfColorGrayscaleTable ( const ossimRpfColorGrayscaleTable rhs)

Definition at line 24 of file ossimRpfColorGrayscaleTable.cpp.

27  theTableId(0),
28  theData(NULL)
29 {
30  *this = rhs;
31 }

◆ ~ossimRpfColorGrayscaleTable()

ossimRpfColorGrayscaleTable::~ossimRpfColorGrayscaleTable ( )
virtual

Definition at line 34 of file ossimRpfColorGrayscaleTable.cpp.

References theData.

35 {
36  if(theData)
37  {
38  delete [] theData;
39  theData = NULL;
40  }
41 }

Member Function Documentation

◆ getData()

const unsigned char* ossimRpfColorGrayscaleTable::getData ( ) const
inline

Definition at line 25 of file ossimRpfColorGrayscaleTable.h.

References theData.

25 {return theData;}

◆ getNumberOfElements()

unsigned long ossimRpfColorGrayscaleTable::getNumberOfElements ( ) const
inline

Definition at line 28 of file ossimRpfColorGrayscaleTable.h.

References theNumberOfElements.

◆ getStartOfData()

const unsigned char * ossimRpfColorGrayscaleTable::getStartOfData ( unsigned long  entry) const

Definition at line 61 of file ossimRpfColorGrayscaleTable.cpp.

References theData, and theTableId.

62 {
63  unsigned long offset = 0;
64 
65  switch(theTableId)
66  {
67  case 1: // this is in format RGB
68  {
69  offset = 3*entry;
70  break;
71  }
72  case 2: // format RGBM
73  case 4: // format CMYK
74  {
75  offset = 4*entry;
76  break;
77  }
78  case 3: // format M
79  {
80  offset = entry;
81  break;
82  }
83  }
84 
85  return (const unsigned char*)(theData + offset);
86 }

◆ getTableId()

unsigned short ossimRpfColorGrayscaleTable::getTableId ( ) const
inline

Definition at line 27 of file ossimRpfColorGrayscaleTable.h.

References theTableId.

◆ operator=()

const ossimRpfColorGrayscaleTable & ossimRpfColorGrayscaleTable::operator= ( const ossimRpfColorGrayscaleTable rhs)

Definition at line 131 of file ossimRpfColorGrayscaleTable.cpp.

References theData, theNumberOfElements, theTableId, and theTotalNumberOfBytes.

132 {
133 
134  if(&rhs != this)
135  {
138  theTableId = rhs.theTableId;
139  if(theData)
140  {
141  delete theData;
142  theData = NULL;
143  }
145  {
146  theData = new unsigned char[theTotalNumberOfBytes];
147 
148  memcpy(theData, rhs.theData, theTotalNumberOfBytes);
149  }
150  }
151 
152  return *this;
153 }

◆ parseStream()

ossimErrorCode ossimRpfColorGrayscaleTable::parseStream ( std::istream &  in,
ossimByteOrder  byteOrder 
)

Definition at line 43 of file ossimRpfColorGrayscaleTable.cpp.

References ossimErrorCodes::OSSIM_ERROR, ossimErrorCodes::OSSIM_OK, theData, and theTotalNumberOfBytes.

45 {
46  if(in)
47  {
49  {
50  in.read((char*)theData, theTotalNumberOfBytes);
51  }
52  }
53  else
54  {
56  }
57 
59 }
static const ossimErrorCode OSSIM_OK
static const ossimErrorCode OSSIM_ERROR

◆ setTableData()

void ossimRpfColorGrayscaleTable::setTableData ( unsigned short  id,
unsigned long  numberOfElements 
)

Definition at line 88 of file ossimRpfColorGrayscaleTable.cpp.

References theData, theNumberOfElements, theTableId, and theTotalNumberOfBytes.

90 {
91  if(theData)
92  {
93  delete theData;
94  theData = NULL;
95  }
96 
97  unsigned long totalBytes = 0;
98 
99  switch(id)
100  {
101  case 1: // this is in format RGB
102  {
103  totalBytes = 3*numberOfElements;
104  break;
105  }
106  case 2: // format RGBM
107  case 4: // format CMYK
108  {
109  totalBytes = 4*numberOfElements;
110  break;
111  }
112  case 3: // format M
113  {
114  totalBytes = numberOfElements;
115  break;
116  }
117  }
118 
119  if(totalBytes > 0)
120  {
121  theTableId = id;
122  theNumberOfElements = numberOfElements;
123  theTotalNumberOfBytes = totalBytes;
124 
125  theData = new unsigned char[totalBytes];
126  }
127 }

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const ossimRpfColorGrayscaleTable data 
)
friend

Definition at line 6 of file ossimRpfColorGrayscaleTable.cpp.

8 {
9  out << "theNumberOfElements: " << data.theNumberOfElements
10  << "\ntheTotalNumberOfBytes: " << data.theTotalNumberOfBytes
11  << "\ntheTableId: " << data.theTableId;
12 
13  return out;
14 }

Member Data Documentation

◆ theData

unsigned char* ossimRpfColorGrayscaleTable::theData
private

◆ theNumberOfElements

unsigned long ossimRpfColorGrayscaleTable::theNumberOfElements
private

◆ theTableId

unsigned short ossimRpfColorGrayscaleTable::theTableId
private

This will not be parsed from the stream. This is set when reading the offset record for this table. The id defines the format of the data buffer. if the id is :

1 then the buffer is in the format of RGB 2 "" RGBM 3 "" M 4 "" CMYK

Definition at line 45 of file ossimRpfColorGrayscaleTable.h.

Referenced by getStartOfData(), getTableId(), operator<<(), operator=(), and setTableData().

◆ theTotalNumberOfBytes

unsigned long ossimRpfColorGrayscaleTable::theTotalNumberOfBytes
private

Definition at line 33 of file ossimRpfColorGrayscaleTable.h.

Referenced by operator<<(), operator=(), parseStream(), and setTableData().


The documentation for this class was generated from the following files: