Skip to content

Commit

Permalink
set grid properties through ImageItem
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Nov 5, 2024
1 parent 9021567 commit e08176f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libheif/api/libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImageItem_Grid>(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 {
Expand Down
13 changes: 8 additions & 5 deletions libheif/image-items/grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ Result<std::shared_ptr<ImageItem_Grid>> 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<HeifPixelImage>& image,
struct heif_encoder* encoder)
{
Expand All @@ -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<Box_pixi>();
file->add_property(grid_id, pixi, true);
add_property(pixi, true);

return Error::Ok;
}
Expand Down Expand Up @@ -752,11 +752,14 @@ Result<std::shared_ptr<ImageItem_Grid>> 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<Box_ispe>();
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

Expand Down
2 changes: 1 addition & 1 deletion libheif/image-items/grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<HeifPixelImage>& image,
struct heif_encoder* encoder);

Expand Down

0 comments on commit e08176f

Please sign in to comment.