diff --git a/libheif/image-items/image_item.cc b/libheif/image-items/image_item.cc index e5c655ee89..baf71af659 100644 --- a/libheif/image-items/image_item.cc +++ b/libheif/image-items/image_item.cc @@ -69,11 +69,19 @@ std::shared_ptr ImageItem::get_file() const heif_property_id ImageItem::add_property(std::shared_ptr property, bool essential) { + // TODO: is this correct? What happens when add_property does deduplicate the property? m_properties.push_back(property); return get_file()->add_property(get_id(), property, essential); } +heif_property_id ImageItem::add_property_without_deduplication(std::shared_ptr property, bool essential) +{ + m_properties.push_back(property); + return get_file()->add_property_without_deduplication(get_id(), property, essential); +} + + Error ImageItem::init_decoder_from_item(heif_item_id id) { m_id = id; diff --git a/libheif/image-items/image_item.h b/libheif/image-items/image_item.h index d13d565bdc..2d222a4fdb 100644 --- a/libheif/image-items/image_item.h +++ b/libheif/image-items/image_item.h @@ -114,6 +114,8 @@ class ImageItem : public ErrorBuffer heif_property_id add_property(std::shared_ptr property, bool essential); + heif_property_id add_property_without_deduplication(std::shared_ptr property, bool essential); + void set_resolution(uint32_t w, uint32_t h) { m_width = w; diff --git a/libheif/image-items/unc_image.cc b/libheif/image-items/unc_image.cc index 10593f98a2..98adbd5a11 100644 --- a/libheif/image-items/unc_image.cc +++ b/libheif/image-items/unc_image.cc @@ -336,19 +336,19 @@ Result> ImageItem_uncompressed::add_unci assert(headers.uncC); if (headers.uncC) { - file->add_property(unci_id, headers.uncC, true); + unci_image->add_property(headers.uncC, true); } if (headers.cmpd) { - file->add_property(unci_id, headers.cmpd, true); + unci_image->add_property(headers.cmpd, true); } // Add `ispe` property - file->add_ispe_property(unci_id, - static_cast(parameters->image_width), - static_cast(parameters->image_height), - true); + auto ispe = std::make_shared(); + ispe->set_size(static_cast(parameters->image_width), + static_cast(parameters->image_height)); + unci_image->add_property(ispe, true); if (parameters->compression != heif_unci_compression_off) { auto icef = std::make_shared(); @@ -374,8 +374,8 @@ Result> ImageItem_uncompressed::add_unci assert(false); } - file->add_property(unci_id, cmpC, true); - file->add_property_without_deduplication(unci_id, icef, true); // icef is empty. A normal add_property() would lead to a wrong deduplication. + unci_image->add_property(cmpC, true); + unci_image->add_property_without_deduplication(icef, true); // icef is empty. A normal add_property() would lead to a wrong deduplication. } // Create empty image. If we use compression, we append the data piece by piece.