comparison Core/DicomParsing/FromDcmtkBridge.cpp @ 3883:795c9ca5eb91 transcoding

DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 05 May 2020 14:11:47 +0200
parents 904575738462
children e23026566536
comparison
equal deleted inserted replaced
3882:904575738462 3883:795c9ca5eb91
1288 * Note that up to Orthanc 0.7.1 (inclusive), the 1288 * Note that up to Orthanc 0.7.1 (inclusive), the
1289 * "EXS_LittleEndianExplicit" was always used to save the DICOM 1289 * "EXS_LittleEndianExplicit" was always used to save the DICOM
1290 * dataset into memory. We now keep the original transfer syntax 1290 * dataset into memory. We now keep the original transfer syntax
1291 * (if available). 1291 * (if available).
1292 **/ 1292 **/
1293 E_TransferSyntax xfer = dataSet.getOriginalXfer(); 1293 E_TransferSyntax xfer = dataSet.getCurrentXfer();
1294 if (xfer == EXS_Unknown) 1294 if (xfer == EXS_Unknown)
1295 { 1295 {
1296 // No information about the original transfer syntax: This is 1296 // No information about the original transfer syntax: This is
1297 // most probably a DICOM dataset that was read from memory. 1297 // most probably a DICOM dataset that was read from memory.
1298 xfer = EXS_LittleEndianExplicit; 1298 xfer = EXS_LittleEndianExplicit;
1308 1308
1309 1309
1310 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer, 1310 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer,
1311 DcmFileFormat& dicom) 1311 DcmFileFormat& dicom)
1312 { 1312 {
1313 E_TransferSyntax xfer = dicom.getDataset()->getOriginalXfer(); 1313 E_TransferSyntax xfer = dicom.getDataset()->getCurrentXfer();
1314 if (xfer == EXS_Unknown) 1314 if (xfer == EXS_Unknown)
1315 { 1315 {
1316 throw OrthancException(ErrorCode_InternalError, 1316 throw OrthancException(ErrorCode_InternalError,
1317 "Cannot write a DICOM instance with unknown transfer syntax"); 1317 "Cannot write a DICOM instance with unknown transfer syntax");
1318 } 1318 }
1336 if (!LookupDcmtkTransferSyntax(xfer, syntax)) 1336 if (!LookupDcmtkTransferSyntax(xfer, syntax))
1337 { 1337 {
1338 throw OrthancException(ErrorCode_InternalError); 1338 throw OrthancException(ErrorCode_InternalError);
1339 } 1339 }
1340 else 1340 else
1341 { 1341 {
1342 if (!dicom.getDataset()->chooseRepresentation(xfer, representation).good() || 1342 if (!dicom.getDataset()->chooseRepresentation(xfer, representation).good() ||
1343 !dicom.getDataset()->canWriteXfer(xfer) || 1343 !dicom.getDataset()->canWriteXfer(xfer) ||
1344 !dicom.validateMetaInfo(xfer, EWM_updateMeta).good()) 1344 !dicom.validateMetaInfo(xfer, EWM_updateMeta).good())
1345 { 1345 {
1346 return false; 1346 return false;
1347 } 1347 }
1348 else 1348 else
1349 { 1349 {
1350 dicom.removeInvalidGroups(); 1350 dicom.removeInvalidGroups();
1351
1352 DicomTransferSyntax sourceSyntax;
1353 if (LookupOrthancTransferSyntax(sourceSyntax, dicom))
1354 {
1355 LOG(INFO) << "Transcoded an image from transfer syntax "
1356 << GetTransferSyntaxUid(sourceSyntax) << " to "
1357 << GetTransferSyntaxUid(syntax);
1358 }
1359 else
1360 {
1361 LOG(INFO) << "Transcoded an image from unknown transfer syntax to "
1362 << GetTransferSyntaxUid(syntax);
1363 }
1364
1351 return true; 1365 return true;
1352 } 1366 }
1353 } 1367 }
1354 } 1368 }
1355 1369
1806 } 1820 }
1807 1821
1808 DcmPixelData& pixelData = dynamic_cast<DcmPixelData&>(*element); 1822 DcmPixelData& pixelData = dynamic_cast<DcmPixelData&>(*element);
1809 DcmPixelSequence* pixelSequence = NULL; 1823 DcmPixelSequence* pixelSequence = NULL;
1810 if (!pixelData.getEncapsulatedRepresentation 1824 if (!pixelData.getEncapsulatedRepresentation
1811 (dataset.getOriginalXfer(), NULL, pixelSequence).good()) 1825 (dataset.getCurrentXfer(), NULL, pixelSequence).good())
1812 { 1826 {
1813 return NULL; 1827 return NULL;
1814 } 1828 }
1815 else 1829 else
1816 { 1830 {
2668 throw OrthancException(ErrorCode_InternalError); 2682 throw OrthancException(ErrorCode_InternalError);
2669 } 2683 }
2670 2684
2671 DcmDataset& dataset = *dicom.getDataset(); 2685 DcmDataset& dataset = *dicom.getDataset();
2672 2686
2673 E_TransferSyntax xfer = dataset.getOriginalXfer(); 2687 E_TransferSyntax xfer = dataset.getCurrentXfer();
2674 if (xfer == EXS_Unknown) 2688 if (xfer == EXS_Unknown)
2675 { 2689 {
2676 dataset.updateOriginalXfer(); 2690 dataset.updateOriginalXfer();
2677 xfer = dataset.getOriginalXfer(); 2691 xfer = dataset.getOriginalXfer();
2678 if (xfer == EXS_Unknown) 2692 if (xfer == EXS_Unknown)