21 #ifndef LIBHEIF_HEIF_CXX_H
22 #define LIBHEIF_HEIF_CXX_H
61 std::string m_message;
69 class EncoderParameter;
70 class EncoderDescriptor;
95 virtual int read(
void* data,
size_t size) = 0;
144 const void* data,
int size);
148 const void* data,
int size);
164 std::shared_ptr<heif_context> m_context;
183 bool empty() const noexcept {
return !m_image_handle; }
230 std::shared_ptr<heif_image_handle> m_image_handle;
242 void create(
int width,
int height,
248 int width,
int height,
int bit_depth);
273 std::shared_ptr<heif_image> m_image;
283 static std::vector<EncoderDescriptor>
285 const char* name_filter) noexcept;
287 std::string
get_name()
const noexcept;
313 std::string
get_name()
const noexcept;
358 void set_parameter(std::string parameter_name, std::string parameter_value);
364 std::shared_ptr<heif_encoder> m_encoder;
377 m_context = std::shared_ptr<heif_context>(ctx,
410 return reader->
read(data,size);
452 std::vector<heif_item_id> IDs(num);
488 context.m_context = std::shared_ptr<heif_context>(ctx,
504 return writer->
write(data, size);
530 if (handle !=
nullptr) {
531 m_image_handle = std::shared_ptr<heif_image_handle>(handle,
564 std::vector<heif_item_id> IDs(num);
591 return Image(out_img);
598 std::vector<heif_item_id> ids(nBlocks);
601 ids.data(), nBlocks);
619 std::vector<uint8_t> data(data_size);
634 m_image = std::shared_ptr<heif_image>(image,
649 m_image = std::shared_ptr<heif_image>(image,
655 int width,
int height,
int bit_depth) {
708 inline std::vector<EncoderDescriptor>
710 const char* name_filter) noexcept {
711 int maxDescriptors = 10;
722 if (nDescriptors < maxDescriptors) {
723 std::vector<EncoderDescriptor> outDescriptors;
724 for (
int i=0;i<nDescriptors;i++) {
728 delete[] descriptors;
730 return outDescriptors;
733 delete[] descriptors;
778 m_encoder = std::shared_ptr<heif_encoder>(encoder,
784 m_encoder = std::shared_ptr<heif_encoder>(encoder,
807 int have_minimum_maximum;
809 &have_minimum_maximum,
810 &out_minimum, &out_maximum));
815 return have_minimum_maximum;
827 const char*
const* stringarray;
834 std::vector<std::string> values;
835 for (
int i=0; stringarray[i]; i++) {
836 values.push_back(stringarray[i]);
843 std::vector<EncoderParameter> parameters;
909 const int max_size = 250;
910 char value[max_size];
921 parameter_value.c_str()));
928 const int max_size = 250;
929 char value[max_size];
964 encoder.m_encoder.get(),
985 encoder.m_encoder.get(),
988 &thumb_image_handle));
1008 const void* data,
int size) {
1018 const void* data,
int size) {
Definition: heif_cxx.h:119
EncodingOptions()
Definition: heif_cxx.h:947
Definition: heif_cxx.h:90
virtual ~Reader()
Definition: heif_cxx.h:92
virtual heif_reader_grow_status wait_for_file_size(int64_t target_size)=0
virtual int read(void *data, size_t size)=0
virtual int64_t get_position() const =0
virtual int seek(int64_t position)=0
Definition: heif_cxx.h:78
Definition: heif_cxx.h:150
virtual ~Writer()
Definition: heif_cxx.h:152
virtual heif_error write(const void *data, size_t size)=0
Definition: heif_cxx.h:74
void write_to_file(std::string filename) const
Definition: heif_cxx.h:520
void read_from_memory(const void *mem, size_t size, const ReadingOptions &opts=ReadingOptions())
Definition: heif_cxx.h:388
heif_item_id get_primary_image_ID() const
Definition: heif_cxx.h:457
void read_from_memory_without_copy(const void *mem, size_t size, const ReadingOptions &opts=ReadingOptions())
Definition: heif_cxx.h:395
void assign_thumbnail(const ImageHandle &thumbnail_image, const ImageHandle &master_image)
Definition: heif_cxx.h:997
ImageHandle get_primary_image_handle() const
Definition: heif_cxx.h:466
void set_primary_image(ImageHandle &new_primary_image_handle)
Definition: heif_cxx.h:938
void read_from_file(std::string filename, const ReadingOptions &opts=ReadingOptions())
Definition: heif_cxx.h:381
int get_number_of_top_level_images() const noexcept
Definition: heif_cxx.h:442
ImageHandle encode_image(const Image &img, Encoder &encoder, const EncodingOptions &options=EncodingOptions())
Definition: heif_cxx.h:958
friend struct ::heif_error heif_writer_trampoline_write(struct heif_context *ctx, const void *data, size_t size, void *userdata)
Definition: heif_cxx.h:494
ImageHandle get_image_handle(heif_item_id id) const
Definition: heif_cxx.h:476
bool is_top_level_image_ID(heif_item_id id) const noexcept
Definition: heif_cxx.h:446
void read_from_reader(Reader &, const ReadingOptions &opts=ReadingOptions())
Definition: heif_cxx.h:433
void write(Writer &)
Definition: heif_cxx.h:513
std::vector< heif_item_id > get_list_of_top_level_image_IDs() const noexcept
Definition: heif_cxx.h:450
Context()
Definition: heif_cxx.h:375
void add_XMP_metadata(const ImageHandle &master_image, const void *data, int size)
Definition: heif_cxx.h:1017
ImageHandle encode_thumbnail(const Image &image, const ImageHandle &master_image, Encoder &encoder, const EncodingOptions &, int bbox_size)
Definition: heif_cxx.h:975
void add_exif_metadata(const ImageHandle &master_image, const void *data, int size)
Definition: heif_cxx.h:1007
Definition: heif_cxx.h:281
static std::vector< EncoderDescriptor > get_encoder_descriptors(enum heif_compression_format format_filter, const char *name_filter) noexcept
Definition: heif_cxx.h:709
Encoder get_encoder() const
Definition: heif_cxx.h:760
bool supportes_lossless_compression() const noexcept
Definition: heif_cxx.h:756
enum heif_compression_format get_compression_format() const noexcept
Definition: heif_cxx.h:748
bool supportes_lossy_compression() const noexcept
Definition: heif_cxx.h:752
std::string get_name() const noexcept
Definition: heif_cxx.h:740
std::string get_id_name() const noexcept
Definition: heif_cxx.h:744
Definition: heif_cxx.h:311
std::vector< std::string > get_valid_string_values() const
Definition: heif_cxx.h:826
bool is_boolean() const noexcept
Definition: heif_cxx.h:818
std::string get_name() const noexcept
Definition: heif_cxx.h:794
bool is_string() const noexcept
Definition: heif_cxx.h:822
bool is_integer() const noexcept
Definition: heif_cxx.h:802
enum heif_encoder_parameter_type get_type() const noexcept
Definition: heif_cxx.h:798
bool get_valid_integer_range(int &out_minimum, int &out_maximum)
Definition: heif_cxx.h:806
Definition: heif_cxx.h:336
std::vector< EncoderParameter > list_parameters() const noexcept
Definition: heif_cxx.h:842
bool get_boolean_parameter(std::string parameter_name) const
Definition: heif_cxx.h:892
void set_integer_parameter(std::string parameter_name, int value)
Definition: heif_cxx.h:869
void set_lossless(bool enable_lossless)
Definition: heif_cxx.h:862
void set_parameter(std::string parameter_name, std::string parameter_value)
Definition: heif_cxx.h:919
void set_lossy_quality(int quality)
Definition: heif_cxx.h:855
std::string get_string_parameter(std::string parameter_name) const
Definition: heif_cxx.h:908
void set_boolean_parameter(std::string parameter_name, bool value)
Definition: heif_cxx.h:885
Encoder(enum heif_compression_format format)
Definition: heif_cxx.h:771
void set_string_parameter(std::string parameter_name, std::string value)
Definition: heif_cxx.h:901
std::string get_parameter(std::string parameter_name) const
Definition: heif_cxx.h:927
int get_integer_parameter(std::string parameter_name) const
Definition: heif_cxx.h:876
heif_error_code get_code() const
Definition: heif_cxx.h:52
heif_suberror_code get_subcode() const
Definition: heif_cxx.h:54
std::string get_message() const
Definition: heif_cxx.h:50
Error()
Definition: heif_cxx.h:38
Error(const heif_error &err)
Definition: heif_cxx.h:44
Definition: heif_cxx.h:219
Definition: heif_cxx.h:177
heif_image_handle * get_raw_image_handle() noexcept
Definition: heif_cxx.h:226
std::string get_metadata_type(heif_item_id metadata_id) const noexcept
Definition: heif_cxx.h:607
ImageHandle()
Definition: heif_cxx.h:179
bool is_primary_image() const noexcept
Definition: heif_cxx.h:536
std::string get_metadata_content_type(heif_item_id metadata_id) const noexcept
Definition: heif_cxx.h:611
const heif_image_handle * get_raw_image_handle() const noexcept
Definition: heif_cxx.h:227
int get_number_of_thumbnails() const noexcept
Definition: heif_cxx.h:558
Image decode_image(heif_colorspace colorspace, heif_chroma chroma, const DecodingOptions &options=DecodingOptions())
Definition: heif_cxx.h:579
ImageHandle get_thumbnail(heif_item_id id)
Definition: heif_cxx.h:569
bool has_alpha_channel() const noexcept
Definition: heif_cxx.h:548
int get_height() const noexcept
Definition: heif_cxx.h:544
std::vector< heif_item_id > get_list_of_metadata_block_IDs(const char *type_filter=nullptr) const noexcept
Definition: heif_cxx.h:595
std::vector< heif_item_id > get_list_of_thumbnail_IDs() const noexcept
Definition: heif_cxx.h:562
bool empty() const noexcept
Definition: heif_cxx.h:183
std::vector< uint8_t > get_metadata(heif_item_id) const
Definition: heif_cxx.h:615
int get_width() const noexcept
Definition: heif_cxx.h:540
Definition: heif_cxx.h:266
Definition: heif_cxx.h:235
int get_height(enum heif_channel channel) const noexcept
Definition: heif_cxx.h:674
bool has_channel(enum heif_channel channel) const noexcept
Definition: heif_cxx.h:682
void add_plane(enum heif_channel channel, int width, int height, int bit_depth)
Definition: heif_cxx.h:654
void create(int width, int height, enum heif_colorspace colorspace, enum heif_chroma chroma)
Definition: heif_cxx.h:639
const uint8_t * get_plane(enum heif_channel channel, int *out_stride) const noexcept
Definition: heif_cxx.h:686
Image()
Definition: heif_cxx.h:237
heif_chroma get_chroma_format() const noexcept
Definition: heif_cxx.h:666
heif_colorspace get_colorspace() const noexcept
Definition: heif_cxx.h:662
int get_width(enum heif_channel channel) const noexcept
Definition: heif_cxx.h:670
int get_bits_per_pixel(enum heif_channel channel) const noexcept
Definition: heif_cxx.h:678
Image scale_image(int width, int height, const ScalingOptions &options=ScalingOptions()) const
Definition: heif_cxx.h:694
LIBHEIF_API int heif_context_get_encoder_descriptors(struct heif_context *, enum heif_compression_format format_filter, const char *name_filter, const struct heif_encoder_descriptor **out_encoders, int count)
LIBHEIF_API struct heif_error heif_encoder_set_parameter_string(struct heif_encoder *, const char *parameter_name, const char *value)
LIBHEIF_API struct heif_error heif_context_read_from_memory_without_copy(struct heif_context *, const void *mem, size_t size, const struct heif_reading_options *)
LIBHEIF_API struct heif_error heif_image_handle_get_thumbnail(const struct heif_image_handle *main_image_handle, heif_item_id thumbnail_id, struct heif_image_handle **out_thumbnail_handle)
LIBHEIF_API size_t heif_image_handle_get_metadata_size(const struct heif_image_handle *handle, heif_item_id metadata_id)
LIBHEIF_API struct heif_error heif_context_get_primary_image_ID(struct heif_context *ctx, heif_item_id *id)
LIBHEIF_API struct heif_error heif_context_write(struct heif_context *, struct heif_writer *writer, void *userdata)
LIBHEIF_API int heif_context_is_top_level_image_ID(struct heif_context *ctx, heif_item_id id)
LIBHEIF_API struct heif_error heif_context_get_encoder(struct heif_context *context, const struct heif_encoder_descriptor *, struct heif_encoder **out_encoder)
LIBHEIF_API struct heif_error heif_context_get_primary_image_handle(struct heif_context *ctx, struct heif_image_handle **)
heif_channel
Definition: heif.h:748
LIBHEIF_API uint8_t * heif_image_get_plane(struct heif_image *, enum heif_channel channel, int *out_stride)
heif_colorspace
Definition: heif.h:741
heif_chroma
Definition: heif.h:722
LIBHEIF_API struct heif_error heif_encoder_get_parameter_string(struct heif_encoder *, const char *parameter_name, char *value, int value_size)
LIBHEIF_API const uint8_t * heif_image_get_plane_readonly(const struct heif_image *, enum heif_channel channel, int *out_stride)
LIBHEIF_API int heif_image_handle_get_list_of_thumbnail_IDs(const struct heif_image_handle *handle, heif_item_id *ids, int count)
LIBHEIF_API struct heif_error heif_encoder_get_parameter_integer(struct heif_encoder *, const char *parameter_name, int *value)
LIBHEIF_API struct heif_error heif_context_encode_thumbnail(struct heif_context *, const struct heif_image *image, const struct heif_image_handle *master_image_handle, struct heif_encoder *encoder, const struct heif_encoding_options *options, int bbox_size, struct heif_image_handle **out_thumb_image_handle)
LIBHEIF_API struct heif_error heif_encoder_set_parameter(struct heif_encoder *, const char *parameter_name, const char *value)
LIBHEIF_API struct heif_error heif_context_read_from_reader(struct heif_context *, const struct heif_reader *reader, void *userdata, const struct heif_reading_options *)
LIBHEIF_API void heif_context_free(struct heif_context *)
LIBHEIF_API int heif_image_handle_get_width(const struct heif_image_handle *handle)
LIBHEIF_API struct heif_error heif_context_add_exif_metadata(struct heif_context *, const struct heif_image_handle *image_handle, const void *data, int size)
LIBHEIF_API struct heif_error heif_context_add_XMP_metadata(struct heif_context *, const struct heif_image_handle *image_handle, const void *data, int size)
LIBHEIF_API enum heif_colorspace heif_image_get_colorspace(const struct heif_image *)
LIBHEIF_API struct heif_error heif_context_get_image_handle(struct heif_context *ctx, heif_item_id id, struct heif_image_handle **)
heif_suberror_code
Definition: heif.h:124
@ heif_suberror_Unspecified
Definition: heif.h:126
LIBHEIF_API struct heif_error heif_encoder_set_lossless(struct heif_encoder *, int enable)
LIBHEIF_API struct heif_encoding_options * heif_encoding_options_alloc()
LIBHEIF_API int heif_image_handle_get_height(const struct heif_image_handle *handle)
LIBHEIF_API int heif_image_get_bits_per_pixel(const struct heif_image *, enum heif_channel channel)
LIBHEIF_API struct heif_error heif_context_read_from_file(struct heif_context *, const char *filename, const struct heif_reading_options *)
LIBHEIF_API int heif_encoder_descriptor_supportes_lossy_compression(const struct heif_encoder_descriptor *)
LIBHEIF_API enum heif_encoder_parameter_type heif_encoder_parameter_get_type(const struct heif_encoder_parameter *)
heif_error_code
Definition: heif.h:91
@ heif_error_Ok
Definition: heif.h:93
LIBHEIF_API const char * heif_encoder_descriptor_get_name(const struct heif_encoder_descriptor *)
heif_compression_format
Definition: heif.h:715
LIBHEIF_API int heif_image_get_height(const struct heif_image *, enum heif_channel channel)
LIBHEIF_API struct heif_error heif_encoder_get_parameter(struct heif_encoder *, const char *parameter_name, char *value_ptr, int value_size)
LIBHEIF_API struct heif_error heif_encoder_parameter_get_valid_string_values(const struct heif_encoder_parameter *, const char *const **out_stringarray)
LIBHEIF_API struct heif_error heif_encoder_set_lossy_quality(struct heif_encoder *, int quality)
LIBHEIF_API int heif_image_has_channel(const struct heif_image *, enum heif_channel channel)
LIBHEIF_API const char * heif_encoder_parameter_get_name(const struct heif_encoder_parameter *)
uint32_t heif_item_id
Definition: heif.h:276
LIBHEIF_API struct heif_error heif_context_set_primary_image(struct heif_context *, struct heif_image_handle *image_handle)
heif_reader_grow_status
Definition: heif.h:349
LIBHEIF_API struct heif_context * heif_context_alloc(void)
LIBHEIF_API int heif_encoder_descriptor_supportes_lossless_compression(const struct heif_encoder_descriptor *)
LIBHEIF_API struct heif_error heif_encoder_get_parameter_boolean(struct heif_encoder *, const char *parameter_name, int *value)
LIBHEIF_API int heif_context_get_list_of_top_level_image_IDs(struct heif_context *ctx, heif_item_id *ID_array, int count)
LIBHEIF_API const char * heif_encoder_descriptor_get_id_name(const struct heif_encoder_descriptor *)
LIBHEIF_API struct heif_error heif_image_scale_image(const struct heif_image *input, struct heif_image **output, int width, int height, const struct heif_scaling_options *options)
LIBHEIF_API int heif_image_handle_has_alpha_channel(const struct heif_image_handle *)
LIBHEIF_API struct heif_error heif_image_create(int width, int height, enum heif_colorspace colorspace, enum heif_chroma chroma, struct heif_image **out_image)
LIBHEIF_API int heif_image_handle_get_list_of_metadata_block_IDs(const struct heif_image_handle *handle, const char *type_filter, heif_item_id *ids, int count)
LIBHEIF_API int heif_context_get_number_of_top_level_images(struct heif_context *ctx)
LIBHEIF_API struct heif_error heif_encoder_set_parameter_integer(struct heif_encoder *, const char *parameter_name, int value)
LIBHEIF_API void heif_encoder_release(struct heif_encoder *)
LIBHEIF_API int heif_image_handle_get_number_of_metadata_blocks(const struct heif_image_handle *handle, const char *type_filter)
LIBHEIF_API struct heif_error heif_encoder_parameter_get_valid_integer_range(const struct heif_encoder_parameter *, int *have_minimum_maximum, int *minimum, int *maximum)
LIBHEIF_API const char * heif_image_handle_get_metadata_type(const struct heif_image_handle *handle, heif_item_id metadata_id)
LIBHEIF_API struct heif_error heif_context_get_encoder_for_format(struct heif_context *context, enum heif_compression_format format, struct heif_encoder **)
LIBHEIF_API struct heif_error heif_encoder_set_parameter_boolean(struct heif_encoder *, const char *parameter_name, int value)
LIBHEIF_API const struct heif_encoder_parameter *const * heif_encoder_list_parameters(struct heif_encoder *)
LIBHEIF_API int heif_image_handle_is_primary_image(const struct heif_image_handle *handle)
LIBHEIF_API enum heif_chroma heif_image_get_chroma_format(const struct heif_image *)
LIBHEIF_API struct heif_error heif_image_handle_get_metadata(const struct heif_image_handle *handle, heif_item_id metadata_id, void *out_data)
LIBHEIF_API void heif_encoding_options_free(struct heif_encoding_options *)
LIBHEIF_API void heif_image_release(const struct heif_image *)
LIBHEIF_API struct heif_error heif_context_encode_image(struct heif_context *, const struct heif_image *image, struct heif_encoder *encoder, const struct heif_encoding_options *options, struct heif_image_handle **out_image_handle)
LIBHEIF_API struct heif_error heif_context_write_to_file(struct heif_context *, const char *filename)
LIBHEIF_API enum heif_compression_format heif_encoder_descriptor_get_compression_format(const struct heif_encoder_descriptor *)
LIBHEIF_API int heif_image_get_width(const struct heif_image *, enum heif_channel channel)
LIBHEIF_API int heif_image_handle_get_number_of_thumbnails(const struct heif_image_handle *handle)
LIBHEIF_API struct heif_error heif_context_assign_thumbnail(struct heif_context *, const struct heif_image_handle *master_image, const struct heif_image_handle *thumbnail_image)
LIBHEIF_API void heif_image_handle_release(const struct heif_image_handle *)
LIBHEIF_API const char * heif_image_handle_get_metadata_content_type(const struct heif_image_handle *handle, heif_item_id metadata_id)
LIBHEIF_API struct heif_error heif_context_read_from_memory(struct heif_context *, const void *mem, size_t size, const struct heif_reading_options *)
heif_encoder_parameter_type
Definition: heif.h:1030
@ heif_encoder_parameter_type_boolean
Definition: heif.h:1032
@ heif_encoder_parameter_type_integer
Definition: heif.h:1031
@ heif_encoder_parameter_type_string
Definition: heif.h:1033
LIBHEIF_API struct heif_error heif_image_add_plane(struct heif_image *image, enum heif_channel channel, int width, int height, int bit_depth)
LIBHEIF_API struct heif_error heif_decode_image(const struct heif_image_handle *in_handle, struct heif_image **out_img, enum heif_colorspace colorspace, enum heif_chroma chroma, const struct heif_decoding_options *options)
qulonglong value
Definition: itemviewutilities.cpp:592
@ Image
Definition: coredbconstants.h:98
Definition: bitstream.h:41
int heif_reader_trampoline_read(void *data, size_t size, void *userdata)
Definition: heif_cxx.h:408
int heif_reader_trampoline_seek(int64_t position, void *userdata)
Definition: heif_cxx.h:413
int64_t heif_reader_trampoline_get_position(void *userdata)
Definition: heif_cxx.h:403
struct ::heif_error heif_writer_trampoline_write(struct heif_context *ctx, const void *data, size_t size, void *userdata)
Definition: heif_cxx.h:494
heif_reader_grow_status heif_reader_trampoline_wait_for_file_size(int64_t target_size, void *userdata)
Definition: heif_cxx.h:418
Definition: heif_api_structs.h:45
Definition: heif_plugin_registry.h:37
Definition: heif_plugin.h:208
Definition: heif_api_structs.h:51
const char * message
Definition: heif.h:272
enum heif_suberror_code subcode
Definition: heif.h:269
enum heif_error_code code
Definition: heif.h:266
Definition: heif_api_structs.h:30
std::shared_ptr< heif::HeifContext::Image > image
Definition: heif_api_structs.h:31
std::shared_ptr< heif::HeifContext > context
Definition: heif_api_structs.h:34
Definition: heif_api_structs.h:39