0
votes

I am using DCMTK to write DICOM files to disk and this works quite well. So, I briefly do something as follows:

DcmDataset * ds = image->dcm_file_format->getDataset();
// Modify DICOM as needed...
DcmFileFormat file_format(ds);
file_format.saveFile(filename);

This works quite well. However, I would like to write the contents to some memory buffer. So, I would like to do something as follows:

char * buffer = new char[file_length];

and then somehow use the file_format to write to this buffer instead of the file. I see there is a 'write' method in the DcmFileFormat but could not figure out how to use it where I could specify my own byte array for it to write to.

1

1 Answers

0
votes

You can give a look at the source code of Orthanc, a lightweight Vendor Neutral Archive for medical imaging. Orthanc writes its DICOM instances to memory buffers (std::string) in the method Orthanc::FromDcmtkBridge::SaveToMemoryBuffer(). Here is a direct link to this method.