Commit 375f10ef for libheif
commit 375f10efbf8aa485af1ee6b461fbb8c695263d5f
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Thu May 14 21:36:35 2026 +0200
simplification
diff --git a/libheif/api/libheif/heif_image.h b/libheif/api/libheif/heif_image.h
index 13e99521..aee9c85a 100644
--- a/libheif/api/libheif/heif_image.h
+++ b/libheif/api/libheif/heif_image.h
@@ -196,7 +196,7 @@ enum heif_chroma heif_image_get_chroma_format(const heif_image*);
* @return the width of the channel in pixels, or -1 the channel does not exist in the image
*/
LIBHEIF_API
-int heif_image_get_width(const heif_image* img, enum heif_channel channel);
+int heif_image_get_width(const heif_image* img, heif_channel channel);
/**
* Get the height of a specified image channel.
@@ -206,7 +206,7 @@ int heif_image_get_width(const heif_image* img, enum heif_channel channel);
* @return the height of the channel in pixels, or -1 the channel does not exist in the image
*/
LIBHEIF_API
-int heif_image_get_height(const heif_image* img, enum heif_channel channel);
+int heif_image_get_height(const heif_image* img, heif_channel channel);
/**
* Get the width of the main channel.
diff --git a/libheif/image/pixelimage.cc b/libheif/image/pixelimage.cc
index 0182c820..bcd9bb43 100644
--- a/libheif/image/pixelimage.cc
+++ b/libheif/image/pixelimage.cc
@@ -717,9 +717,8 @@ uint32_t HeifPixelImage::get_primary_component_id() const
// second pass: if we have a cmpd table, use component types
- for (uint32_t idx = 0; idx < m_storage.size(); idx++) {
- uint16_t comp_type = get_component_type(m_storage[idx].m_component_ids[0]);
- switch (comp_type) {
+ for (const auto& comp : get_component_descriptions()) {
+ switch (comp.component_type) {
case heif_unci_component_type_Y:
case heif_unci_component_type_monochrome:
case heif_unci_component_type_red:
@@ -731,7 +730,7 @@ uint32_t HeifPixelImage::get_primary_component_id() const
case heif_unci_component_type_key_black:
case heif_unci_component_type_filter_array:
case heif_unci_component_type_palette:
- return m_storage[idx].m_component_ids[0];
+ return comp.component_id;
default:
; // NOP
diff --git a/libheif/image/pixelimage.h b/libheif/image/pixelimage.h
index e62b6406..6bb649a2 100644
--- a/libheif/image/pixelimage.h
+++ b/libheif/image/pixelimage.h
@@ -80,8 +80,10 @@ public:
// Has alpha information either as a separate channel or in the interleaved format.
bool has_alpha() const;
+ // Get logical image size. Individual components may vary.
uint32_t get_width() const { return m_width; }
+ // Get logical image size. Individual components may vary.
uint32_t get_height() const { return m_height; }
uint32_t get_width(heif_channel channel) const;
@@ -332,7 +334,7 @@ private:
// bytes_per_component * m_num_interleaved_components.
uint8_t m_bytes_per_pixel = 0;
- // the "visible" area of the plane
+ // the "visible" area of the component
uint32_t m_width = 0;
uint32_t m_height = 0;