Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/dicom.imageio/dicominput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ DICOMInput::seek_subimage(int subimage, int miplevel)

if (subimage < m_subimage) {
// Want an earlier subimage, Easier to close and start again
close();
m_subimage = -1;
close(); // note: resets m_subimge to -1
}

// Open if it's not already opened
Expand Down Expand Up @@ -183,8 +182,12 @@ DICOMInput::seek_subimage(int subimage, int miplevel)
++m_subimage;
}

m_dipixel = m_img->getInterData();
m_internal_data = (const char*)m_dipixel->getData();
m_dipixel = m_img->getInterData();
if (!m_dipixel) {
errorfmt("Unable to read pixel data from DICOM file {}", m_filename);
m_img.reset();
return false;
}
EP_Representation rep = m_dipixel->getRepresentation();
TypeDesc format;
switch (rep) {
Expand All @@ -197,6 +200,11 @@ DICOMInput::seek_subimage(int subimage, int miplevel)
default: break;
}
m_internal_data = (const char*)m_img->getOutputData(0, m_subimage, 0);
if (!m_internal_data) {
errorfmt("Unable to decode pixel data from DICOM file {}", m_filename);
m_img.reset();
return false;
}

EP_Interpretation photo = m_img->getPhotometricInterpretation();
struct PhotoTable {
Expand Down
Loading