Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

gdcm::RLEFramesInfo Class Reference

Utility class for gathering the informations of the collection of RLE frame[s] (see RLEFrame) when handling "Encapsulated RLE Compressed Images" (see PS 3.5-2003 annex G). Note: a classical image can be considered as the degenerated case of a multiframe image. In this case the collection is limited to a single individual frame. The informations on each frame are obtained during the pixel parsing of a gdcm::File (refer to File::ComputeRLEInfo() ). They shall be used when (if necessary) decoding the frames. More...

#include <gdcmRLEFramesInfo.h>

List of all members.

Private Types

typedef std::list< RLEFrame * > RLEFrameList

Private Member Functions

 ~RLEFramesInfo ()
void Print (std::ostream &os=std::cout, std::string indent="")
 Print self.
bool DecompressRLEFile (std::ifstream *fp, uint8_t *subRaw, int xSize, int ySize, int zSize, int bitsAllocated)
 Reads from disk the Pixel Data of 'Run Length Encoded' Dicom encapsulated file and decompress it.
bool ConvertRLE16BitsFromRLE8Bits (uint8_t *subRaw, int xSize, int ySize, int numberOfFrames)
 We assume Raw contains the decoded RLE pixels but as 8 bits per pixel. We convert those pixels to 16 bits per pixel.
void AddFrame (RLEFrame *frame)
RLEFrameGetFirstFrame ()
RLEFrameGetNextFrame ()

Private Attributes

RLEFrameList Frames
RLEFrameList::iterator ItFrames

Friends

class PixelReadConvert
class File


Detailed Description

Utility class for gathering the informations of the collection of RLE frame[s] (see RLEFrame) when handling "Encapsulated RLE Compressed Images" (see PS 3.5-2003 annex G). Note: a classical image can be considered as the degenerated case of a multiframe image. In this case the collection is limited to a single individual frame. The informations on each frame are obtained during the pixel parsing of a gdcm::File (refer to File::ComputeRLEInfo() ). They shall be used when (if necessary) decoding the frames.

This class is simply a stl list<> of RLEFrame.

Definition at line 43 of file gdcmRLEFramesInfo.h.


Member Typedef Documentation

typedef std::list<RLEFrame *> gdcm::RLEFramesInfo::RLEFrameList [private]
 

Definition at line 62 of file gdcmRLEFramesInfo.h.


Constructor & Destructor Documentation

gdcm::RLEFramesInfo::~RLEFramesInfo  )  [private]
 

Definition at line 27 of file gdcmRLEFramesInfo.cxx.

References Frames.

00028 {
00029    for(RLEFrameList::iterator it = Frames.begin(); it != Frames.end(); ++it)
00030    {
00031       delete (*it);
00032    }
00033    Frames.clear();
00034 }


Member Function Documentation

void gdcm::RLEFramesInfo::AddFrame RLEFrame frame  )  [private]
 

Definition at line 38 of file gdcmRLEFramesInfo.cxx.

References Frames.

Referenced by gdcm::File::ComputeRLEInfo().

00039 {
00040    Frames.push_back(frame);
00041 }

bool gdcm::RLEFramesInfo::ConvertRLE16BitsFromRLE8Bits uint8_t *  raw,
int  xSize,
int  ySize,
int  numberOfFrames
[private]
 

We assume Raw contains the decoded RLE pixels but as 8 bits per pixel. We convert those pixels to 16 bits per pixel.

Parameters:
raw raw
xSize x Size
ySize y Size
numberOfFrames number of frames
Returns:
Boolean always true

Definition at line 105 of file gdcmRLEFramesInfo.cxx.

References gdcm::Util::IsCurrentProcessorBigEndian().

Referenced by DecompressRLEFile().

00107 {
00108    size_t pixelNumber = xSize * ySize;
00109    size_t rawSize     = pixelNumber * numberOfFrames * 2;
00110 
00111    // We assumed Raw contains the decoded RLE pixels but as
00112    // 8 bits per pixel. In order to convert those pixels to 16 bits
00113    // per pixel we cannot work in place within Raw and hence
00114    // we copy it in a safe place, say copyRaw.
00115 
00116    uint8_t *copyRaw = new uint8_t[rawSize];
00117    memmove( copyRaw, raw, rawSize );
00118 
00119    uint8_t *x = raw;
00120    uint8_t *a;
00121    uint8_t *b;
00122 
00123    // Warning : unckecked patch to see the behaviour on Big Endian Processors
00124 
00125    if ( !Util::IsCurrentProcessorBigEndian() )
00126    { 
00127       a = copyRaw;         // beginning of 'low bytes'
00128       b = a + pixelNumber; // beginning of 'hight bytes'
00129    }
00130    else
00131    {
00132       b = copyRaw;         // beginning of 'low bytes'
00133       a = b + pixelNumber; // beginning of 'hight bytes'
00134    } 
00135 
00136    // Re order bytes
00137    for ( int i = 0; i < numberOfFrames; i++ )
00138    {
00139       for ( unsigned int j = 0; j < pixelNumber; j++ )
00140       {
00141          *(x++) = *(b++);
00142          *(x++) = *(a++);
00143       }
00144    }
00145 
00146    delete[] copyRaw;
00147 
00148    return true;
00149 }

bool gdcm::RLEFramesInfo::DecompressRLEFile std::ifstream *  fp,
uint8_t *  raw,
int  xSize,
int  ySize,
int  zSize,
int  bitsAllocated
[private]
 

Reads from disk the Pixel Data of 'Run Length Encoded' Dicom encapsulated file and decompress it.

Parameters:
fp already open File Pointer from which the pixel data should be read
raw raw
xSize x Size
ySize y Size
zSize z Size
bitsAllocated Bits allocated
Returns:
Boolean

Definition at line 73 of file gdcmRLEFramesInfo.cxx.

References ConvertRLE16BitsFromRLE8Bits(), and Frames.

Referenced by gdcm::PixelReadConvert::ReadAndDecompressPixelData().

00076 {
00077    uint8_t *subRaw = raw;
00078    long rawSegmentSize = xSize * ySize;
00079 
00080    // Loop on the frame[s]
00081    for(RLEFrameList::iterator it = Frames.begin(); it != Frames.end(); ++it)
00082    {
00083       subRaw = (*it)->ReadAndDecompressRLEFrame( subRaw, rawSegmentSize, fp);
00084    }
00085 
00086    if ( bitsAllocated == 16 )
00087    {
00088       // Try to deal with RLE 16 Bits
00089       ConvertRLE16BitsFromRLE8Bits( raw, xSize, ySize, zSize );
00090    }
00091 
00092    return true;
00093 }

RLEFrame * gdcm::RLEFramesInfo::GetFirstFrame  )  [private]
 

Definition at line 43 of file gdcmRLEFramesInfo.cxx.

References Frames, and ItFrames.

00044 {
00045    ItFrames = Frames.begin();
00046    if (ItFrames != Frames.end())
00047       return  *ItFrames;
00048    return NULL;
00049 }

RLEFrame * gdcm::RLEFramesInfo::GetNextFrame  )  [private]
 

Definition at line 51 of file gdcmRLEFramesInfo.cxx.

References Frames, gdcmAssertMacro, and ItFrames.

00052 {
00053    gdcmAssertMacro (ItFrames != Frames.end());
00054 
00055    ++ItFrames;
00056    if (ItFrames != Frames.end())
00057       return  *ItFrames;
00058    return NULL;
00059 }

void gdcm::RLEFramesInfo::Print std::ostream &  os = std::cout,
std::string  indent = ""
[private]
 

Print self.

Parameters:
indent Indentation string to be prepended during printing.
os Stream to print to.

Definition at line 164 of file gdcmRLEFramesInfo.cxx.

References Frames.

00165 {
00166    os << std::endl;
00167    os << indent
00168       << "----------------- RLE frames --------------------------------"
00169       << std::endl;
00170    os << indent
00171       << "Total number of Frames : " << Frames.size()
00172       << std::endl;
00173    int frameNumber = 0;
00174    for(RLEFrameList::iterator it = Frames.begin(); it != Frames.end(); ++it)
00175    {
00176       os << indent
00177          << "   frame number :" << frameNumber++
00178          << std::endl;
00179       (*it)->Print( os, indent + "   " );
00180    }
00181 }


Friends And Related Function Documentation

friend class File [friend]
 

Definition at line 46 of file gdcmRLEFramesInfo.h.

friend class PixelReadConvert [friend]
 

Definition at line 45 of file gdcmRLEFramesInfo.h.


Member Data Documentation

RLEFrameList gdcm::RLEFramesInfo::Frames [private]
 

Definition at line 64 of file gdcmRLEFramesInfo.h.

Referenced by AddFrame(), DecompressRLEFile(), GetFirstFrame(), GetNextFrame(), Print(), and ~RLEFramesInfo().

RLEFrameList::iterator gdcm::RLEFramesInfo::ItFrames [private]
 

Definition at line 65 of file gdcmRLEFramesInfo.h.

Referenced by GetFirstFrame(), and GetNextFrame().


The documentation for this class was generated from the following files:
Generated on Fri Jan 20 10:14:37 2006 for gdcm by  doxygen 1.4.4