diff --git a/libheif/heif.cc b/libheif/heif.cc index c06aa01514..9c8364ffd7 100644 --- a/libheif/heif.cc +++ b/libheif/heif.cc @@ -790,6 +790,14 @@ int heif_image_handle_get_ispe_height(const struct heif_image_handle* handle) } +struct heif_context* heif_image_handle_get_context(const struct heif_image_handle* handle) +{ + auto ctx = new heif_context(); + ctx->context = handle->context; + return ctx; +} + + struct heif_error heif_image_handle_get_preferred_decoding_colorspace(const struct heif_image_handle* image_handle, enum heif_colorspace* out_colorspace, enum heif_chroma* out_chroma) diff --git a/libheif/heif.h b/libheif/heif.h index 4821fcb488..976a45e040 100644 --- a/libheif/heif.h +++ b/libheif/heif.h @@ -864,6 +864,17 @@ int heif_image_handle_get_ispe_width(const struct heif_image_handle* handle); LIBHEIF_API int heif_image_handle_get_ispe_height(const struct heif_image_handle* handle); +// This gets the context associated with the image handle. +// Note that you have to release the returned context with heif_context_free() in any case. +// +// This means: when you have several image-handles that originate from the same file and you get the +// context of each of them, the returned pointer may be different even though it refers to the same +// logical context. You have to call heif_context_free() on all those context pointers. +// After you freed a context pointer, you can still use the context through a different pointer that you +// might have acquired from elsewhere. +LIBHEIF_API +struct heif_context* heif_image_handle_get_context(const struct heif_image_handle* handle); + // ------------------------- depth images -------------------------