Skip to content

Commit

Permalink
return error from heif_image_handle_get_grid_image_tile_id()
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 6, 2024
1 parent a616322 commit 1328459
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
20 changes: 14 additions & 6 deletions libheif/api/libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -881,23 +881,31 @@ heif_error heif_image_handle_get_image_tiling(const struct heif_image_handle* ha
}


heif_item_id heif_image_handle_get_grid_image_tile_id(const struct heif_image_handle* handle, uint32_t tile_x, uint32_t tile_y)
struct heif_error heif_image_handle_get_grid_image_tile_id(const struct heif_image_handle* handle,
uint32_t tile_x, uint32_t tile_y, heif_item_id* tile_item_id)
{
if (!handle) {
return 0;
if (!handle || !tile_item_id) {
return { heif_error_Usage_error,
heif_suberror_Null_pointer_argument };
}

std::shared_ptr<ImageItem_Grid> gridItem = std::dynamic_pointer_cast<ImageItem_Grid>(handle->image);
if (!gridItem) {
return 0;
return { heif_error_Usage_error,
heif_suberror_Unspecified,
"Image is no grid image" };
}

const ImageGrid& gridspec = gridItem->get_grid_spec();
if (tile_x >= gridspec.get_columns() || tile_y >= gridspec.get_rows()) {
return 0;
return { heif_error_Usage_error,
heif_suberror_Unspecified,
"Grid tile index out of range" };
}

return gridItem->get_grid_tiles()[tile_y * gridspec.get_columns() + tile_x];
*tile_item_id = gridItem->get_grid_tiles()[tile_y * gridspec.get_columns() + tile_x];

return heif_error_ok;
}


Expand Down
4 changes: 2 additions & 2 deletions libheif/api/libheif/heif.h
Original file line number Diff line number Diff line change
Expand Up @@ -1213,8 +1213,8 @@ struct heif_error heif_image_handle_get_image_tiling(const struct heif_image_han
// For grid images, return the image item ID of a specific grid tile. Note that the tile position is given in
// the original, non-transformed image.
LIBHEIF_API
heif_item_id heif_image_handle_get_grid_image_tile_id(const struct heif_image_handle* handle,
uint32_t tile_x, uint32_t tile_y);
struct heif_error heif_image_handle_get_grid_image_tile_id(const struct heif_image_handle* handle,
uint32_t tile_x, uint32_t tile_y, heif_item_id* tile_item_id);


struct heif_decoding_options;
Expand Down
1 change: 1 addition & 0 deletions libheif/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "error.h"

#include "libheif/heif.h"
#include "libheif/heif_experimental.h"
#include "libheif/heif_plugin.h"
#include "bitstream.h"

Expand Down
1 change: 1 addition & 0 deletions libheif/image-items/tild.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <string>
#include <memory>
#include <utility>
#include "libheif/heif_experimental.h"


uint64_t number_of_tiles(const heif_tild_image_parameters& params);
Expand Down

0 comments on commit 1328459

Please sign in to comment.