Mercurial > hg > orthanc
changeset 6488:10784233f0e0
allow ParsedDicomFile::GetRawFrameForInplaceModification() only if host endianness matches
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Tue, 25 Nov 2025 14:50:47 +0100 |
| parents | d7bbe6dc90ba |
| children | 08fdc3215398 |
| files | OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h |
| diffstat | 2 files changed, 28 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp Tue Nov 25 14:31:39 2025 +0100 +++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp Tue Nov 25 14:50:47 2025 +0100 @@ -1824,15 +1824,36 @@ } } - ImageAccessor* ParsedDicomFile::GetRawFrame(unsigned int frame) + ImageAccessor* ParsedDicomFile::GetRawFrameForInplaceModification(unsigned int frame) { E_TransferSyntax transferSyntax = GetDcmtkObjectConst().getDataset()->getCurrentXfer(); - if (transferSyntax != EXS_LittleEndianImplicit && - transferSyntax != EXS_BigEndianImplicit && - transferSyntax != EXS_LittleEndianExplicit && - transferSyntax != EXS_BigEndianExplicit) + + bool ok = false; + switch (Toolbox::DetectEndianness()) { - throw OrthancException(ErrorCode_NotImplemented, "ParseDicomFile::GetRawFrame only works with uncompressed transfer syntaxes"); + case Endianness_Little: + if (transferSyntax == EXS_LittleEndianImplicit || + transferSyntax == EXS_LittleEndianExplicit) + { + ok = true; + } + break; + + case Endianness_Big: + if (transferSyntax == EXS_BigEndianImplicit || + transferSyntax == EXS_BigEndianExplicit) + { + ok = true; + } + break; + + default: + throw OrthancException(ErrorCode_InternalError); + } + + if (!ok) + { + throw OrthancException(ErrorCode_NotImplemented, "ParsedDicomFile::GetRawFrameForInplaceModification() only works with uncompressed transfer syntaxes and matching host endianness"); } if (pimpl_->frameIndex_.get() == NULL)
--- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h Tue Nov 25 14:31:39 2025 +0100 +++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h Tue Nov 25 14:50:47 2025 +0100 @@ -318,7 +318,7 @@ // Returns an image accessor to the raw frame only if the DicomFile is in an uncompressed TS. // This enables modification of pixels data in place. - ImageAccessor* GetRawFrame(unsigned int frame); + ImageAccessor* GetRawFrameForInplaceModification(unsigned int frame); void InjectEmptyPixelData(ValueRepresentation vr);
