Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp @ 4845:02d77189d8ba received-instance-callback
added ReceivedInstanceCallback + sample C++ plugin
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 09 Dec 2021 17:22:40 +0100 |
parents | 7053502fbf97 |
children | 43e613a7756b |
comparison
equal
deleted
inserted
replaced
4844:55e8fb8e8028 | 4845:02d77189d8ba |
---|---|
1193 | 1193 |
1194 case MimeType_Pam: | 1194 case MimeType_Pam: |
1195 EmbedImage(mime, content); | 1195 EmbedImage(mime, content); |
1196 break; | 1196 break; |
1197 | 1197 |
1198 case MimeType_Binary: | |
1199 EmbedImage(mime, content); | |
1200 break; | |
1201 | |
1198 case MimeType_Pdf: | 1202 case MimeType_Pdf: |
1199 EmbedPdf(content); | 1203 EmbedPdf(content); |
1200 break; | 1204 break; |
1201 | 1205 |
1202 default: | 1206 default: |
1249 // "true" means "enforce memory alignment": This is slower, | 1253 // "true" means "enforce memory alignment": This is slower, |
1250 // but possibly avoids crash related to non-aligned memory access | 1254 // but possibly avoids crash related to non-aligned memory access |
1251 PamReader reader(true); | 1255 PamReader reader(true); |
1252 reader.ReadFromMemory(content); | 1256 reader.ReadFromMemory(content); |
1253 EmbedImage(reader); | 1257 EmbedImage(reader); |
1258 break; | |
1259 } | |
1260 | |
1261 case MimeType_Binary: | |
1262 { | |
1263 EmbedRawPixelData(content); | |
1254 break; | 1264 break; |
1255 } | 1265 } |
1256 | 1266 |
1257 default: | 1267 default: |
1258 throw OrthancException(ErrorCode_NotImplemented); | 1268 throw OrthancException(ErrorCode_NotImplemented); |
1405 { | 1415 { |
1406 throw OrthancException(ErrorCode_InternalError); | 1416 throw OrthancException(ErrorCode_InternalError); |
1407 } | 1417 } |
1408 } | 1418 } |
1409 | 1419 |
1410 | 1420 void ParsedDicomFile::EmbedRawPixelData(const std::string& content) |
1421 { | |
1422 DcmTag key(DICOM_TAG_PIXEL_DATA.GetGroup(), | |
1423 DICOM_TAG_PIXEL_DATA.GetElement()); | |
1424 | |
1425 std::unique_ptr<DcmPixelData> pixels(new DcmPixelData(key)); | |
1426 | |
1427 Uint8* target = NULL; | |
1428 pixels->createUint8Array(content.size(), target); | |
1429 memcpy(target, content.c_str(), content.size()); | |
1430 | |
1431 if (!GetDcmtkObject().getDataset()->insert(pixels.release(), false, false).good()) | |
1432 { | |
1433 throw OrthancException(ErrorCode_InternalError); | |
1434 } | |
1435 } | |
1436 | |
1437 | |
1411 Encoding ParsedDicomFile::DetectEncoding(bool& hasCodeExtensions) const | 1438 Encoding ParsedDicomFile::DetectEncoding(bool& hasCodeExtensions) const |
1412 { | 1439 { |
1413 return FromDcmtkBridge::DetectEncoding(hasCodeExtensions, | 1440 return FromDcmtkBridge::DetectEncoding(hasCodeExtensions, |
1414 *GetDcmtkObjectConst().getDataset(), | 1441 *GetDcmtkObjectConst().getDataset(), |
1415 GetDefaultDicomEncoding()); | 1442 GetDefaultDicomEncoding()); |