Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | 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.

Public 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 Types

typedef std::list< RLEFrame * > RLEFrameList

Private Attributes

RLEFrameList Frames
RLEFrameList::iterator ItFrames


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 59 of file gdcmRLEFramesInfo.h.


Constructor & Destructor Documentation

gdcm::RLEFramesInfo::~RLEFramesInfo  ) 
 

Definition at line 26 of file gdcmRLEFramesInfo.cxx.

References Frames.

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


Member Function Documentation

void gdcm::RLEFramesInfo::AddFrame RLEFrame frame  ) 
 

Definition at line 37 of file gdcmRLEFramesInfo.cxx.

References Frames.

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

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

bool gdcm::RLEFramesInfo::ConvertRLE16BitsFromRLE8Bits uint8_t *  raw,
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.

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

Todo:
check that operator new [] didn't fail, and sometimes return false

Definition at line 104 of file gdcmRLEFramesInfo.cxx.

Referenced by DecompressRLEFile().

00106 {
00107    size_t pixelNumber = xSize * ySize;
00108    size_t rawSize = xSize * ySize * numberOfFrames;
00109 
00110    // We assumed Raw contains the decoded RLE pixels but as
00111    // 8 bits per pixel. In order to convert those pixels to 16 bits
00112    // per pixel we cannot work in place within Raw and hence
00113    // we copy it in a safe place, say copyRaw.
00114 
00115    uint8_t *copyRaw = new uint8_t[rawSize * 2];
00116    memmove( copyRaw, raw, rawSize * 2 );
00117 
00118    uint8_t *x = raw;
00119    uint8_t *a = copyRaw;
00120    uint8_t *b = a + pixelNumber;
00121 
00122    for ( int i = 0; i < numberOfFrames; i++ )
00123    {
00124       for ( unsigned int j = 0; j < pixelNumber; j++ )
00125       {
00126          *(x++) = *(b++);
00127          *(x++) = *(a++);
00128       }
00129    }
00130    delete[] copyRaw;
00131 
00133 
00134    return true;
00135 }

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

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

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

Definition at line 72 of file gdcmRLEFramesInfo.cxx.

References ConvertRLE16BitsFromRLE8Bits(), and Frames.

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

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

RLEFrame * gdcm::RLEFramesInfo::GetFirstFrame  ) 
 

Definition at line 42 of file gdcmRLEFramesInfo.cxx.

References Frames, and ItFrames.

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

RLEFrame * gdcm::RLEFramesInfo::GetNextFrame  ) 
 

Definition at line 50 of file gdcmRLEFramesInfo.cxx.

References Frames, gdcmAssertMacro, and ItFrames.

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

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

Print self.

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

Definition at line 150 of file gdcmRLEFramesInfo.cxx.

References Frames.

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

00151 {
00152    os << std::endl;
00153    os << indent
00154       << "----------------- RLE frames --------------------------------"
00155       << std::endl;
00156    os << indent
00157       << "Total number of Frames : " << Frames.size()
00158       << std::endl;
00159    int frameNumber = 0;
00160    for(RLEFrameList::iterator it = Frames.begin(); it != Frames.end(); ++it)
00161    {
00162       os << indent
00163          << "   frame number :" << frameNumber++
00164          << std::endl;
00165       (*it)->Print( os, indent + "   " );
00166    }
00167 }


Member Data Documentation

RLEFrameList gdcm::RLEFramesInfo::Frames [private]
 

Definition at line 61 of file gdcmRLEFramesInfo.h.

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

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

Definition at line 62 of file gdcmRLEFramesInfo.h.

Referenced by GetFirstFrame(), and GetNextFrame().


The documentation for this class was generated from the following files:
Generated on Thu Feb 10 22:18:11 2005 for gdcm by doxygen 1.3.6