Code: Select all
// Get the buffer length
Uint32 meta_length = m_dcm_file_format->getMetaInfo()->calcElementLength(EXS_Unknown, EET_UndefinedLength);
Uint32 data_length = m_dcm_file_format->getDataset()->calcElementLength(EXS_Unknown, EET_UndefinedLength);
// Serialize to buffer which size bigger enough
DcmOutputBufferStream dcm_output_stream(buffer, size);
m_dcm_file_format->transferInit();
OFCondition ret = m_dcm_file_format->write(dcm_output_stream, EXS_Unknown, EET_UndefinedLength, NULL);
m_dcm_file_format->transferEnd();
if (!ret.good()) {
return false;
}
// Get the length after serialization
offile_off_t s = 0;
dcm_output_stream.flushBuffer(buffer, s);
assert(s == (meta_length + data_length)); // Assert failed!!
And I tested several DICOM images and found s - (meta_length + data_length) always seems to be equal to 40.