Код: Выделить всё
void DicomInterface::SaveDicom(const QString &patient_name,
const QString &study_number,
const QString &img_name){
DcmFileFormat file_format(this);
std::string dcm_path = GetSaveDicomPath(patient_name, study_number, img_name);
DJEncoderRegistration::registerCodecs(); // Compress
DJ_RPLossless representation_parameter;
// Save temporal dicom with EXS_LittleEndianExplicit
file_format.saveFile(dcm_path.c_str(),
EXS_LittleEndianExplicit);
// Load the temporal file
OFCondition status = file_format.loadFile(dcm_path.c_str());
DcmDataset *dataset = file_format.getDataset();
// Save compressed Dicom
status = dataset->chooseRepresentation(EXS_JPEGProcess14SV1,
&representation_parameter);
status = file_format.saveFile(dcm_path.c_str(),
EXS_JPEGProcess14SV1);
if (status.bad()) {
qDebug()
Подробнее здесь: [url]https://stackoverflow.com/questions/78284211/save-compressed-dicom-image-without-having-to-temporally-save-uncompressed-dicom[/url]