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.