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
17 changes: 10 additions & 7 deletions src/heif.imageio/heifinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class HeifInput final : public ImageInput {
bool open(const std::string& name, ImageSpec& newspec,
const ImageSpec& config) override;
bool close() override;
int current_subimage(void) const override { return m_subimage; }
bool seek_subimage(int subimage, int miplevel) override;
bool read_native_scanline(int subimage, int miplevel, int y, int z,
void* data) override;
Expand Down Expand Up @@ -188,16 +189,18 @@ HeifInput::open(const std::string& name, ImageSpec& newspec,
try {
m_ctx->read_from_reader(*m_reader);

m_item_ids = m_ctx->get_list_of_top_level_image_IDs();
// Get the item IDs for each subimage, and force the "primary" one to
// have index 0.
m_primary_id = m_ctx->get_primary_image_ID();
for (size_t i = 0; i < m_item_ids.size(); ++i)
if (m_item_ids[i] == m_primary_id) {
m_item_ids.erase(m_item_ids.begin() + i);
break;
}
m_item_ids.resize(0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Perhaps using
m_item_ids = {} would be a bit clearer to the intent

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meh? I appreciate the suggestion, but in this instance, to my eyes the resize is perfectly clear.

m_item_ids.push_back(m_primary_id);
for (auto id : m_ctx->get_list_of_top_level_image_IDs()) {
if (id != m_primary_id)
m_item_ids.push_back(id);
}
// std::cout << " primary id: " << m_primary_id << "\n";
// std::cout << " item ids: " << Strutil::join(m_item_ids, ", ") << "\n";
m_num_subimages = 1 + int(m_item_ids.size());
m_num_subimages = int(m_item_ids.size());

} catch (const heif::Error& err) {
std::string e = err.get_message();
Expand Down
Loading