From e08176fe4f0038dad74626948de173f39b237304 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Wed, 6 Nov 2024 00:04:08 +0100 Subject: [PATCH] set grid properties through ImageItem --- libheif/api/libheif/heif.cc | 2 +- libheif/image-items/grid.cc | 13 ++++++++----- libheif/image-items/grid.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libheif/api/libheif/heif.cc b/libheif/api/libheif/heif.cc index 8bdd2add46..f875418bfa 100644 --- a/libheif/api/libheif/heif.cc +++ b/libheif/api/libheif/heif.cc @@ -3650,7 +3650,7 @@ struct heif_error heif_context_add_image_tile(struct heif_context* ctx, } #endif else if (auto grid_item = std::dynamic_pointer_cast(tiled_image->image)) { - Error err = grid_item->add_image_tile(tiled_image->image->get_id(), tile_x, tile_y, image->image, encoder); + Error err = grid_item->add_image_tile(tile_x, tile_y, image->image, encoder); return err.error_struct(ctx->context.get()); } else { diff --git a/libheif/image-items/grid.cc b/libheif/image-items/grid.cc index 6d739e9566..2bd3f1d183 100644 --- a/libheif/image-items/grid.cc +++ b/libheif/image-items/grid.cc @@ -658,7 +658,7 @@ Result> ImageItem_Grid::add_new_grid_item(HeifCo } -Error ImageItem_Grid::add_image_tile(heif_item_id grid_id, uint32_t tile_x, uint32_t tile_y, +Error ImageItem_Grid::add_image_tile(uint32_t tile_x, uint32_t tile_y, const std::shared_ptr& image, struct heif_encoder* encoder) { @@ -679,13 +679,13 @@ Error ImageItem_Grid::add_image_tile(heif_item_id grid_id, uint32_t tile_x, uint // Assign tile to grid heif_image_tiling tiling = get_heif_image_tiling(); - file->set_iref_reference(grid_id, fourcc("dimg"), tile_y * tiling.num_columns + tile_x, encoded_image->get_id()); + file->set_iref_reference(get_id(), fourcc("dimg"), tile_y * tiling.num_columns + tile_x, encoded_image->get_id()); set_grid_tile_id(tile_x, tile_y, encoded_image->get_id()); // Add PIXI property (copy from first tile) auto pixi = encoded_image->get_property(); - file->add_property(grid_id, pixi, true); + add_property(pixi, true); return Error::Ok; } @@ -752,11 +752,14 @@ Result> ImageItem_Grid::add_and_encode_full_grid uint32_t image_width = tile_width * columns; uint32_t image_height = tile_height * rows; - file->add_ispe_property(grid_id, image_width, image_height, false); + + auto ispe = std::make_shared(); + ispe->set_size(image_width, image_height); + griditem->add_property(ispe, false); // Add PIXI property (copy from first tile) - file->add_property(grid_id, pixi_property, true); + griditem->add_property(pixi_property, true); // Set Brands diff --git a/libheif/image-items/grid.h b/libheif/image-items/grid.h index a2811020b8..c269937654 100644 --- a/libheif/image-items/grid.h +++ b/libheif/image-items/grid.h @@ -89,7 +89,7 @@ class ImageItem_Grid : public ImageItem uint16_t tile_columns, const struct heif_encoding_options* encoding_options); - Error add_image_tile(heif_item_id grid_id, uint32_t tile_x, uint32_t tile_y, + Error add_image_tile(uint32_t tile_x, uint32_t tile_y, const std::shared_ptr& image, struct heif_encoder* encoder);