DcmFileFormat initialized with buffer

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
ancrou
Posts: 13
Joined: Tue, 2008-07-01, 16:54
Location: Nancy France

DcmFileFormat initialized with buffer

#1 Post by ancrou »

Hi,

I would like to initialize a DcmFileFormat with buffer.


I have got :
const void *buff //a pointer to the receiver’s contents
unsigned long bufLen //the number of bytes contained in the receiver.


What should I do ?

I tried :

Code: Select all

DcmInputBufferStream* buffer= new DcmInputBufferStream();
buffer->setBuffer(buff, bufLen);
But after that ?

Thinks

Anth

budric
Posts: 29
Joined: Thu, 2007-06-28, 20:48

#2 Post by budric »

I haven't done it myself but I assume you'd use something like

Code: Select all

virtual OFCondition 	read (DcmInputStream &inStream, const E_TransferSyntax xfer=EXS_Unknown, const E_GrpLenEncoding glenc=EGL_noChange, const Uint32 maxReadLength=DCM_MaxReadLength)
http://support.dcmtk.org/docs/classDcmDataset.html
to create your dataset.
then initialize DcmFileFormat with the dataset.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1445
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#3 Post by Marco Eichelberg »

Something like this will do. Note the call to setEos which is important because it tells the buffer stream that the buffer will not be refilled (e.g. from a network connection) once it has been read completely.

Code: Select all

DcmInputBufferStream dataBuf;
dataBuf.setBuffer(buff, bufLen);
dataBuf.setEos();

DcmFileFormat dfile;
dfile.transferInit();
OFCondition cond = dfile.read(dataBuf);
dfile.transferEnd();

if( cond.bad() )
{
  // something went wrong.
}

ancrou
Posts: 13
Joined: Tue, 2008-07-01, 16:54
Location: Nancy France

#4 Post by ancrou »

Marco Eichelberg wrote:Something like this will do. Note the call to setEos which is important because it tells the buffer stream that the buffer will not be refilled (e.g. from a network connection) once it has been read completely.
It's working
Thank you a lot.

Anthony

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest