#include <gdcmRLEFrame.h>
Public Member Functions | |
RLEFrame () | |
void | Print (std::ostream &os=std::cout, std::string indent="") |
Print self. | |
void | SetNumberOfFragments (unsigned int number) |
unsigned int | GetNumberOfFragments () |
void | SetOffset (unsigned int id, long offset) |
long | GetOffset (unsigned int id) |
void | SetLength (unsigned int id, long length) |
long | GetLength (unsigned int id) |
uint8_t * | ReadAndDecompressRLEFrame (uint8_t *subRaw, long rawSegmentSize, std::ifstream *fp) |
bool | ReadAndDecompressRLEFragment (uint8_t *subRaw, long fragmentSize, long rawSegmentSize, std::ifstream *fp) |
Implementation of the RLE decoding algorithm for decompressing a RLE fragment. [refer to PS 3.5-2003, section G.3.2 p 86]. | |
Private Attributes | |
unsigned int | NumberOfFragments |
long | Offset [15] |
long | Length [15] |
Each instance of this class (they can be as many instances for a given Document as they are frames and they are collected in a RLEFramesInfo ) describes :
Definition at line 46 of file gdcmRLEFrame.h.
|
Definition at line 49 of file gdcmRLEFrame.h.
00049 { NumberOfFragments = 0; } |
|
Definition at line 47 of file gdcmRLEFrame.cxx. References gdcmAssertMacro.
00048 { 00049 gdcmAssertMacro(id<15); 00050 return Length[id]; 00051 } |
|
Definition at line 53 of file gdcmRLEFrame.h.
00053 { return NumberOfFragments; }; |
|
Definition at line 35 of file gdcmRLEFrame.cxx. References gdcmAssertMacro.
00036 { 00037 gdcmAssertMacro(id<15); 00038 return Offset[id]; 00039 } |
|
Print self.
Definition at line 143 of file gdcmRLEFrame.cxx. References NumberOfFragments.
00144 { 00145 os << indent 00146 << "--- fragments" 00147 << std::endl; 00148 for ( unsigned int i = 0; i < NumberOfFragments; i++ ) 00149 { 00150 os << indent 00151 << " offset : " << Offset[i] 00152 << " length : " << Length[i] 00153 << std::endl; 00154 } 00155 } |
|
Implementation of the RLE decoding algorithm for decompressing a RLE fragment. [refer to PS 3.5-2003, section G.3.2 p 86].
Definition at line 79 of file gdcmRLEFrame.cxx. References gdcmWarningMacro. Referenced by ReadAndDecompressRLEFrame().
00083 { 00084 int8_t count; 00085 long numberOfOutputBytes = 0; 00086 long numberOfReadBytes = 0; 00087 00088 00089 while( numberOfOutputBytes < rawSegmentSize ) 00090 { 00091 fp->read( (char*)&count, 1 ); 00092 numberOfReadBytes += 1; 00093 if ( count >= 0 ) 00094 // Note: count <= 127 comparison is always true due to limited range 00095 // of data type int8_t [since the maximum of an exact width 00096 // signed integer of width N is 2^(N-1) - 1, which for int8_t 00097 // is 127]. 00098 { 00099 fp->read( (char*)subRaw, count + 1); 00100 numberOfReadBytes += count + 1; 00101 subRaw += count + 1; 00102 numberOfOutputBytes += count + 1; 00103 } 00104 else 00105 { 00106 if ( count <= -1 && count >= -127 ) 00107 { 00108 int8_t newByte; 00109 fp->read( (char*)&newByte, 1); 00110 numberOfReadBytes += 1; 00111 for( int i = 0; i < -count + 1; i++ ) 00112 { 00113 subRaw[i] = newByte; 00114 } 00115 subRaw += -count + 1; 00116 numberOfOutputBytes += -count + 1; 00117 } 00118 } 00119 // if count = 128 output nothing 00120 00121 if ( numberOfReadBytes > fragmentSize ) 00122 { 00123 gdcmWarningMacro( "Read more bytes than the segment size."); 00124 return false; 00125 } 00126 } 00127 return true; 00128 } |
|
Definition at line 53 of file gdcmRLEFrame.cxx. References NumberOfFragments, and ReadAndDecompressRLEFragment().
00056 { 00057 // Loop on the fragments 00058 for( unsigned int k = 1; k <= NumberOfFragments; k++ ) 00059 { 00060 // First thing need to reset file to proper position: 00061 fp->seekg(Offset[k], std::ios::beg); 00062 ReadAndDecompressRLEFragment(subRaw, Length[k], 00063 rawSegmentSize, fp); 00064 subRaw += rawSegmentSize; 00065 } 00066 00067 return subRaw; 00068 } |
|
Definition at line 41 of file gdcmRLEFrame.cxx. References gdcmAssertMacro. Referenced by gdcm::File::ComputeRLEInfo().
00042 { 00043 gdcmAssertMacro(id<15); 00044 Length[id] = length; 00045 } |
|
Definition at line 52 of file gdcmRLEFrame.h. Referenced by gdcm::File::ComputeRLEInfo().
00052 { NumberOfFragments = number; }; |
|
Definition at line 29 of file gdcmRLEFrame.cxx. References gdcmAssertMacro. Referenced by gdcm::File::ComputeRLEInfo().
00030 { 00031 gdcmAssertMacro(id<15); 00032 Offset[id] = offset; 00033 } |
|
Definition at line 67 of file gdcmRLEFrame.h. |
|
Definition at line 65 of file gdcmRLEFrame.h. Referenced by Print(), and ReadAndDecompressRLEFrame(). |
|
Definition at line 66 of file gdcmRLEFrame.h. |