GDCM: gdcm::StreamImageWriter Class Reference

GDCM 3.2.7

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
gdcm::StreamImageWriter Class Reference

StreamImageReader. More...

`#include <gdcmStreamImageWriter.h>`

Collaboration diagram for gdcm::StreamImageWriter:
[legend]

## Public Member Functions
| StreamImageWriter ()
virtual | ~StreamImageWriter ()
bool | CanWriteFile () const
void | DefinePixelExtent (uint16_t inXMin, uint16_t inXMax, uint16_t inYMin, uint16_t inYMax, uint16_t inZMin=0, uint16_t inZMax=1)
uint32_t | DefineProperBufferLength ()
void | SetFile (const File &inFile)
void | SetFileName (const char *inFileName)
void | SetStream (std::ostream &inStream)
bool | Write (void *inWriteBuffer, const std::size_t &inBufferLength)
virtual bool | WriteImageInformation ()

## Protected Member Functions
virtual bool | WriteImageSubregionRAW (char *inWriteBuffer, const std::size_t &inBufferLength)
int | WriteRawHeader (RAWCodec *inCodec, std::ostream *inStream)

## Protected Attributes
int | mElementOffsets
int | mElementOffsets1
SmartPointer< File > | mspFile
Writer | mWriter
uint16_t | mXMax
uint16_t | mXMin
uint16_t | mYMax
uint16_t | mYMin
uint16_t | mZMax
uint16_t | mZMin

## Detailed Description

StreamImageReader.

Note
  its role is to convert the DICOM DataSet into a Image representation via an ITK streaming (ie, multithreaded) interface Image is different from Pixmap has it has a position and a direction in Space. Currently, this class is threadsafe in that it can read a single extent in a single thread. Multiple versions can be used for multiple extents/threads.

See also
  Image

Examples
  Extracting_All_Resolution.cxx, Fake_Image_Using_Stream_Image_Writer.cxx, and StreamImageReaderTest.cxx.

## Constructor & Destructor Documentation

## ◆ StreamImageWriter()

gdcm::StreamImageWriter::StreamImageWriter | ( |  | ) |

## ◆ ~StreamImageWriter()

virtual gdcm::StreamImageWriter::~StreamImageWriter | ( |  | ) |
| virtual

## Member Function Documentation

## ◆ CanWriteFile()

bool gdcm::StreamImageWriter::CanWriteFile | ( |  | ) | const

This function determines if a file can even be written using the streaming writer unlike the reader, can be called before WriteImageInformation, but must be called after SetFile.

Examples
  Extracting_All_Resolution.cxx, and Fake_Image_Using_Stream_Image_Writer.cxx.

## ◆ DefinePixelExtent()

void gdcm::StreamImageWriter::DefinePixelExtent | ( | uint16_t | inXMin,
|  | uint16_t | inXMax,
|  | uint16_t | inYMin,
|  | uint16_t | inYMax,
|  | uint16_t | inZMin = 0,
|  | uint16_t | inZMax = 1 )

Defines an image extent for the Read function. DICOM states that an image can have no more than 2^16 pixels per edge (as of 2009) In this case, the pixel extents ignore the direction cosines entirely, and assumes that the origin of the image is at location 0,0 (regardless of the definition in space per the tags). So, if the first 100 pixels of the first row are to be read in, this function should be called with DefinePixelExtent(0, 100, 0, 1), regardless of pixel size or orientation. 15 nov 2010: added z dimension, defaults to being 1 plane large

Examples
  Extracting_All_Resolution.cxx, Fake_Image_Using_Stream_Image_Writer.cxx, and StreamImageReaderTest.cxx.

## ◆ DefineProperBufferLength()

uint32_t gdcm::StreamImageWriter::DefineProperBufferLength | ( |  | ) |

Paying attention to the pixel format and so forth, define the proper buffer length for the user. The return amount is in bytes. If the return is 0, then that means that the pixel extent was not defined prior this return is for RAW inputs which are then encoded by the writer, but are used to ensure that the writer gets the proper buffer size

Examples
  Extracting_All_Resolution.cxx, Fake_Image_Using_Stream_Image_Writer.cxx, and StreamImageReaderTest.cxx.

## ◆ SetFile()

void gdcm::StreamImageWriter::SetFile | ( | const File & | inFile | ) |

Set the image information to be written to disk that is everything but the pixel information: (7fe0,0010) PixelData

Examples
  Extracting_All_Resolution.cxx, Fake_Image_Using_Stream_Image_Writer.cxx, and StreamImageReaderTest.cxx.

## ◆ SetFileName()

void gdcm::StreamImageWriter::SetFileName | ( | const char * | inFileName | ) |

One of either SetFileName or SetStream must be called prior to any other functions. These initialize an internal Reader class to be able to get non-pixel image information.

## ◆ SetStream()

void gdcm::StreamImageWriter::SetStream | ( | std::ostream & | inStream | ) |

Examples
  Extracting_All_Resolution.cxx, Fake_Image_Using_Stream_Image_Writer.cxx, and StreamImageReaderTest.cxx.

## ◆ Write()

bool gdcm::StreamImageWriter::Write | ( | void * | inWriteBuffer,
|  | const std::size_t & | inBufferLength )

Read the DICOM image. There are three reasons for failure:

1. The extent is not set
2. the conversion from void* to std::ostream (internally) fails
3. the given buffer isn't large enough to accommodate the desired pixel extent. This method has been implemented to look similar to the metaimageio in itk MUST have an extent defined, or else Read will return false. If no particular extent is required, use ImageReader instead.

Examples
  Extracting_All_Resolution.cxx, Fake_Image_Using_Stream_Image_Writer.cxx, and StreamImageReaderTest.cxx.

## ◆ WriteImageInformation()

virtual bool gdcm::StreamImageWriter::WriteImageInformation | ( |  | ) |
| virtual

Write the header information to disk, and a bunch of zeros for the actual pixel information Of course, if we're doing a non-compressed format, that works but if it's compressed, we have to force the ordering of chunks that are written.

Examples
  Extracting_All_Resolution.cxx, Fake_Image_Using_Stream_Image_Writer.cxx, and StreamImageReaderTest.cxx.

## ◆ WriteImageSubregionRAW()

virtual bool gdcm::StreamImageWriter::WriteImageSubregionRAW | ( | char * | inWriteBuffer,
|  | const std::size_t & | inBufferLength )
| protectedvirtual

Using the min, max, etc set by DefinePixelExtent, this will fill the given buffer Make sure to call DefinePixelExtent and to initialize the buffer with the amount given by DefineProperBufferLength prior to calling this. reads by the RAW codec; other codecs are added once implemented

## ◆ WriteRawHeader()

int gdcm::StreamImageWriter::WriteRawHeader | ( | RAWCodec * | inCodec,
|  | std::ostream * | inStream )
| protected

when writing a raw file, we know the full extent, and can just write the first 12 bytes out (the tag, the VR, and the size) when we do compressed files, we'll do it in chunks, as described in 2009-3, part 5, Annex A, section 4. Pass the raw codec so that in the rare case of a bigendian explicit raw, the first 12 bytes written out should still be kosher. returns -1 if there's any failure, or the complete offset (12 bytes) if it works. Those 12 bytes are then added to the position in order to determine where to write.

## Member Data Documentation

## ◆ mElementOffsets

int gdcm::StreamImageWriter::mElementOffsets
| protected

The result of WriteRawHeader (or another header, when that's implemented) This result is saved so that the first N bytes aren't constantly being rewritten for each chunk that's passed in. For compressed data, the offset table will require rewrites of data.

## ◆ mElementOffsets1

int gdcm::StreamImageWriter::mElementOffsets1
| protected

## ◆ mspFile

SmartPointer<File> gdcm::StreamImageWriter::mspFile
| protected

## ◆ mWriter

Writer gdcm::StreamImageWriter::mWriter
| protected

## ◆ mXMax

uint16_t gdcm::StreamImageWriter::mXMax
| protected

## ◆ mXMin

uint16_t gdcm::StreamImageWriter::mXMin
| protected

## ◆ mYMax

uint16_t gdcm::StreamImageWriter::mYMax
| protected

## ◆ mYMin

uint16_t gdcm::StreamImageWriter::mYMin
| protected

## ◆ mZMax

uint16_t gdcm::StreamImageWriter::mZMax
| protected

## ◆ mZMin

uint16_t gdcm::StreamImageWriter::mZMin
| protected

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

- gdcmStreamImageWriter.h