Commit 85deb072 for libheif

commit 85deb072821bfdaf97e90b6baa2bb67317c223fc
Author: Dirk Farin <dirk.farin@gmail.com>
Date:   Sun May 17 19:53:16 2026 +0200

    factor out image component functions into heif_components.h

diff --git a/libheif/CMakeLists.txt b/libheif/CMakeLists.txt
index 27660b22..38ee2d96 100644
--- a/libheif/CMakeLists.txt
+++ b/libheif/CMakeLists.txt
@@ -24,6 +24,7 @@ set(libheif_headers
         api/libheif/heif_image_handle.h
         api/libheif/heif_context.h
         api/libheif/heif_tiling.h
+        api/libheif/heif_components.h
         api/libheif/heif_uncompressed.h
         api/libheif/heif_uncompressed_types.h
         api/libheif/heif_text.h
@@ -93,6 +94,7 @@ set(libheif_sources
         api/libheif/heif_image_handle.cc
         api/libheif/heif_context.cc
         api/libheif/heif_tiling.cc
+        api/libheif/heif_components.cc
         api/libheif/heif_uncompressed.cc
         api/libheif/heif_text.cc
         api/libheif/heif_omaf.cc
diff --git a/libheif/api/libheif/heif.h b/libheif/api/libheif/heif.h
index 085e453f..f7048b81 100644
--- a/libheif/api/libheif/heif.h
+++ b/libheif/api/libheif/heif.h
@@ -37,6 +37,7 @@
 #include <libheif/heif_context.h>
 #include <libheif/heif_image_handle.h>
 #include <libheif/heif_tiling.h>
+#include <libheif/heif_components.h>
 #include <libheif/heif_omaf.h>

 #endif
diff --git a/libheif/api/libheif/heif_components.cc b/libheif/api/libheif/heif_components.cc
new file mode 100644
index 00000000..4d82f977
--- /dev/null
+++ b/libheif/api/libheif/heif_components.cc
@@ -0,0 +1,279 @@
+/*
+ * HEIF codec.
+ * Copyright (c) 2026 Dirk Farin <dirk.farin@gmail.com>
+ *
+ * This file is part of libheif.
+ *
+ * libheif is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * libheif is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libheif.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "heif_components.h"
+#include "api_structs.h"
+#include "image/pixelimage.h"
+
+
+// --- id-based component access on a decoded heif_image
+
+uint32_t heif_image_get_number_of_used_components(const heif_image* image)
+{
+  if (!image || !image->image) {
+    return 0;
+  }
+  return image->image->get_number_of_used_components();
+}
+
+
+void heif_image_get_used_component_ids(const heif_image* image, uint32_t* out_component_ids)
+{
+  if (!image || !image->image || !out_component_ids) {
+    return;
+  }
+
+  auto indices = image->image->get_used_component_ids();
+  for (size_t i = 0; i < indices.size(); i++) {
+    out_component_ids[i] = indices[i];
+  }
+}
+
+
+heif_channel heif_image_get_component_channel(const heif_image* image, uint32_t component_idx)
+{
+  if (!image || !image->image) {
+    return heif_channel_Y;
+  }
+  return image->image->get_component_channel(component_idx);
+}
+
+
+uint32_t heif_image_get_component_width(const heif_image* image, uint32_t component_idx)
+{
+  if (!image || !image->image) {
+    return 0;
+  }
+  return image->image->get_component_width(component_idx);
+}
+
+
+uint32_t heif_image_get_component_height(const heif_image* image, uint32_t component_idx)
+{
+  if (!image || !image->image) {
+    return 0;
+  }
+  return image->image->get_component_height(component_idx);
+}
+
+
+int heif_image_get_component_bits_per_pixel(const heif_image* image, uint32_t component_idx)
+{
+  if (!image || !image->image) {
+    return 0;
+  }
+  return image->image->get_component_bits_per_pixel(component_idx);
+}
+
+
+uint16_t heif_image_get_component_type(const heif_image* image, uint32_t component_idx)
+{
+  if (!image || !image->image) {
+    return 0;
+  }
+  return image->image->get_component_type(component_idx);
+}
+
+
+heif_component_datatype heif_image_get_component_datatype(const heif_image* image, uint32_t component_idx)
+{
+  if (!image || !image->image) {
+    return heif_component_datatype_undefined;
+  }
+  return image->image->get_component_datatype(component_idx);
+}
+
+
+// --- handle-side per-component getters
+//
+// These read from ImageItem::m_components (populated at parse time by
+// ImageItem::populate_component_descriptions). For unci images, the ids are
+// the same numerical values that heif_image_get_used_component_ids() will
+// report after decoding.
+
+uint32_t heif_image_handle_get_number_of_components(const heif_image_handle* handle)
+{
+  if (!handle) {
+    return 0;
+  }
+  return static_cast<uint32_t>(handle->image->get_component_descriptions().size());
+}
+
+
+void heif_image_handle_get_used_component_ids(const heif_image_handle* handle, uint32_t* out_component_ids)
+{
+  if (!handle || !out_component_ids) {
+    return;
+  }
+  const auto& comps = handle->image->get_component_descriptions();
+  for (size_t i = 0; i < comps.size(); i++) {
+    out_component_ids[i] = comps[i].component_id;
+  }
+}
+
+
+uint16_t heif_image_handle_get_component_type(const heif_image_handle* handle, uint32_t component_id)
+{
+  if (!handle) {
+    return 0;
+  }
+  if (auto* desc = handle->image->find_component_description(component_id)) {
+    return desc->component_type;
+  }
+  return 0;
+}
+
+
+int heif_image_handle_get_component_bits_per_pixel(const heif_image_handle* handle, uint32_t component_id)
+{
+  if (!handle) {
+    return -1;
+  }
+  if (auto* desc = handle->image->find_component_description(component_id)) {
+    return static_cast<int>(desc->bit_depth);
+  }
+  return -1;
+}
+
+
+heif_component_datatype heif_image_handle_get_component_datatype(const heif_image_handle* handle, uint32_t component_id)
+{
+  if (!handle) {
+    return heif_component_datatype_undefined;
+  }
+  if (auto* desc = handle->image->find_component_description(component_id)) {
+    return desc->datatype;
+  }
+  return heif_component_datatype_undefined;
+}
+
+
+// --- adding components
+
+heif_error heif_image_add_component(heif_image* image,
+                                    int width, int height,
+                                    uint16_t component_type,
+                                    heif_component_datatype datatype,
+                                    int bit_depth,
+                                    uint32_t* out_component_idx)
+{
+  if (!image || !image->image) {
+    return heif_error_null_pointer_argument;
+  }
+
+  auto result = image->image->add_component(width, height, component_type, datatype, bit_depth, nullptr);
+  if (!result) {
+    return result.error_struct(image->image.get());
+  }
+
+  if (out_component_idx) {
+    *out_component_idx = *result;
+  }
+
+  return heif_error_success;
+}
+
+
+// --- untyped uint8 accessors
+
+const uint8_t* heif_image_get_component_readonly(const heif_image* image, uint32_t component_idx, size_t* out_stride)
+{
+  if (!image || !image->image) {
+    if (out_stride) *out_stride = 0;
+    return nullptr;
+  }
+  return image->image->get_component(component_idx, out_stride);
+}
+
+
+uint8_t* heif_image_get_component(heif_image* image, uint32_t component_idx, size_t* out_stride)
+{
+  if (!image || !image->image) {
+    if (out_stride) *out_stride = 0;
+    return nullptr;
+  }
+  return image->image->get_component(component_idx, out_stride);
+}
+
+
+// Typed accessors: convert the internal byte stride to element count for the
+// public API. libheif's allocator pads rows to a 16-byte boundary (see
+// pixelimage.cc), which is a multiple of sizeof(T) for every supported T
+// (<= 16 bytes), so the division is always exact.
+#define heif_image_get_component_X(name, type) \
+const type* heif_image_get_component_ ## name ## _readonly(const struct heif_image* image, \
+                                                            uint32_t component_idx, \
+                                                            size_t* out_row_elements) \
+{                                                            \
+  if (!image || !image->image) {                             \
+    if (out_row_elements) *out_row_elements = 0;             \
+    return nullptr;                                          \
+  }                                                          \
+  size_t byte_stride = 0;                                    \
+  const type* p = image->image->get_component_memory<type>(component_idx, &byte_stride); \
+  if (out_row_elements) *out_row_elements = byte_stride / sizeof(type); \
+  return p;                                                  \
+}                                                            \
+                                                             \
+type* heif_image_get_component_ ## name (struct heif_image* image, \
+                                         uint32_t component_idx,  \
+                                         size_t* out_row_elements) \
+{                                                            \
+  if (!image || !image->image) {                             \
+    if (out_row_elements) *out_row_elements = 0;             \
+    return nullptr;                                          \
+  }                                                          \
+  size_t byte_stride = 0;                                    \
+  type* p = image->image->get_component_memory<type>(component_idx, &byte_stride); \
+  if (out_row_elements) *out_row_elements = byte_stride / sizeof(type); \
+  return p;                                                  \
+}
+
+heif_image_get_component_X(uint16, uint16_t)
+heif_image_get_component_X(uint32, uint32_t)
+heif_image_get_component_X(uint64, uint64_t)
+heif_image_get_component_X(int8, int8_t)
+heif_image_get_component_X(int16, int16_t)
+heif_image_get_component_X(int32, int32_t)
+heif_image_get_component_X(int64, int64_t)
+heif_image_get_component_X(float32, float)
+heif_image_get_component_X(float64, double)
+heif_image_get_component_X(complex32, heif_complex32)
+heif_image_get_component_X(complex64, heif_complex64)
+
+
+heif_error heif_image_set_gimi_component_content_id(heif_image* image,
+                                                    uint32_t component_id,
+                                                    const char* content_id)
+{
+  if (image == nullptr || content_id == nullptr) {
+    return heif_error_null_pointer_argument;
+  }
+
+  auto* desc = image->image->find_component_description(component_id);
+  if (!desc) {
+    return {heif_error_Usage_error,
+            heif_suberror_Invalid_parameter_value,
+            "No component with the requested component_id exists."};
+  }
+  desc->gimi_content_id = content_id;
+
+  return heif_error_success;
+}
diff --git a/libheif/api/libheif/heif_components.h b/libheif/api/libheif/heif_components.h
new file mode 100644
index 00000000..47ac147b
--- /dev/null
+++ b/libheif/api/libheif/heif_components.h
@@ -0,0 +1,240 @@
+/*
+ * HEIF codec.
+ * Copyright (c) 2026 Dirk Farin <dirk.farin@gmail.com>
+ *
+ * This file is part of libheif.
+ *
+ * libheif is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * libheif is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libheif.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBHEIF_HEIF_COMPONENTS_H
+#define LIBHEIF_HEIF_COMPONENTS_H
+
+#include "libheif/heif_library.h"
+#include "libheif/heif_image.h"
+#include "libheif/heif_image_handle.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* @file heif_components.h
+ * @brief Multi-component image API.
+ *
+ * The component model (id-addressed pixel planes with per-component type,
+ * datatype and bit-depth) is codec-agnostic. It was introduced for ISO 23001-17
+ * (uncompressed) images but is also expected to be reused by other codecs that
+ * carry multiple typed components (e.g. JPEG-2000).
+ */
+
+
+// --- pixel datatype support
+//
+// The numeric values are aligned with the ISO/IEC 23001-17 Table 2
+// component_format byte (used by the uncC box of the uncompressed codec).
+// This is an internal convenience and should not be relied upon.
+
+typedef enum heif_component_datatype
+{
+  heif_component_datatype_unsigned_integer = 0,
+  heif_component_datatype_floating_point   = 1,
+  heif_component_datatype_complex_number   = 2,
+  heif_component_datatype_signed_integer   = 3,
+  heif_component_datatype_undefined        = 0xFF
+} heif_component_datatype;
+
+typedef struct heif_complex32
+{
+  float real, imaginary;
+} heif_complex32;
+
+typedef struct heif_complex64
+{
+  double real, imaginary;
+} heif_complex64;
+
+
+// --- index-based component access (operates on a decoded heif_image)
+
+// Returns the number of components that have pixel data (planes) in this image.
+LIBHEIF_API
+uint32_t heif_image_get_number_of_used_components(const heif_image*);
+
+// Fills `out_component_indices` with the valid component indices.
+// The caller must allocate an array of at least heif_image_get_number_of_used_components() elements.
+LIBHEIF_API
+void heif_image_get_used_component_ids(const heif_image*, uint32_t* out_component_ids);
+
+LIBHEIF_API
+heif_channel heif_image_get_component_channel(const heif_image*, uint32_t component_idx);
+
+LIBHEIF_API
+uint32_t heif_image_get_component_width(const heif_image*, uint32_t component_idx);
+
+LIBHEIF_API
+uint32_t heif_image_get_component_height(const heif_image*, uint32_t component_idx);
+
+LIBHEIF_API
+int heif_image_get_component_bits_per_pixel(const heif_image*, uint32_t component_idx);
+
+LIBHEIF_API
+uint16_t heif_image_get_component_type(const heif_image*, uint32_t component_idx);
+
+// Returns the datatype (unsigned/signed integer, floating point, or complex
+// number) of the given component.
+LIBHEIF_API
+heif_component_datatype heif_image_get_component_datatype(const heif_image*, uint32_t component_idx);
+
+
+// --- ID-based component access via heif_image_handle (before decoding)
+//
+// These let the caller introspect a multi-component image's components without
+// decoding any tile. They return 0 / -1 / heif_component_datatype_undefined for
+// images that do not expose a component model or for unknown component IDs.
+//
+// The component IDs returned here match the IDs that
+// heif_image_get_used_component_ids() will report after the same image is
+// decoded, so the same numerical id can be used to address a component on
+// either side of the API.
+
+LIBHEIF_API
+uint32_t heif_image_handle_get_number_of_components(const heif_image_handle*);
+
+// Fills `out_component_ids` with the valid component IDs.
+// The caller must allocate an array of at least
+// heif_image_handle_get_number_of_components() elements.
+LIBHEIF_API
+void heif_image_handle_get_used_component_ids(const heif_image_handle*, uint32_t* out_component_ids);
+
+LIBHEIF_API
+uint16_t heif_image_handle_get_component_type(const heif_image_handle*, uint32_t component_id);
+
+LIBHEIF_API
+int heif_image_handle_get_component_bits_per_pixel(const heif_image_handle*, uint32_t component_id);
+
+LIBHEIF_API
+heif_component_datatype heif_image_handle_get_component_datatype(const heif_image_handle*, uint32_t component_id);
+
+
+// --- adding components to a heif_image (encoder path)
+
+LIBHEIF_API
+heif_error heif_image_add_component(heif_image* image,
+                                    int width, int height,
+                                    uint16_t component_type,
+                                    heif_component_datatype datatype,
+                                    int bit_depth,
+                                    uint32_t* out_component_idx);
+
+
+// --- untyped uint8 component data getters: stride is in BYTES per row.
+
+LIBHEIF_API
+const uint8_t* heif_image_get_component_readonly(const heif_image*, uint32_t component_idx, size_t* out_stride);
+
+LIBHEIF_API
+uint8_t* heif_image_get_component(heif_image*, uint32_t component_idx, size_t* out_stride);
+
+
+// --- typed component data getters: `out_row_elements` is the number of T
+// elements per row, not bytes. Index with `data[y * row_elements + x]` (no
+// casts, no sizeof). libheif allocates rows with element-aligned padding, so
+// this count is always exact for the named type T.
+
+LIBHEIF_API
+const uint16_t* heif_image_get_component_uint16_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+uint16_t* heif_image_get_component_uint16(heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+const uint32_t* heif_image_get_component_uint32_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+uint32_t* heif_image_get_component_uint32(heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+const uint64_t* heif_image_get_component_uint64_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+uint64_t* heif_image_get_component_uint64(heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+const int8_t* heif_image_get_component_int8_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+int8_t* heif_image_get_component_int8(heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+const int16_t* heif_image_get_component_int16_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+int16_t* heif_image_get_component_int16(heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+const int32_t* heif_image_get_component_int32_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+int32_t* heif_image_get_component_int32(heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+const int64_t* heif_image_get_component_int64_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+int64_t* heif_image_get_component_int64(heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+const float* heif_image_get_component_float32_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+float* heif_image_get_component_float32(heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+const double* heif_image_get_component_float64_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+double* heif_image_get_component_float64(heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+const heif_complex32* heif_image_get_component_complex32_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+heif_complex32* heif_image_get_component_complex32(heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+const heif_complex64* heif_image_get_component_complex64_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+LIBHEIF_API
+heif_complex64* heif_image_get_component_complex64(heif_image*, uint32_t component_idx, size_t* out_row_elements);
+
+
+// --- GIMI component content IDs (set before encoding)
+
+// Set a GIMI component content ID for the component with the given
+// component_id (as minted by heif_image_add_component / returned via the
+// component access API). Pass an empty string to clear a previously set id.
+// Returns an error if no component with this id exists on the image.
+// The collected ids are written into an ItemComponentContentIDProperty box
+// during encoding.
+LIBHEIF_API
+heif_error heif_image_set_gimi_component_content_id(heif_image*,
+                                                    uint32_t component_id,
+                                                    const char* content_id);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libheif/api/libheif/heif_encoding.h b/libheif/api/libheif/heif_encoding.h
index 2906e491..c875bdae 100644
--- a/libheif/api/libheif/heif_encoding.h
+++ b/libheif/api/libheif/heif_encoding.h
@@ -377,7 +377,6 @@ LIBHEIF_API
 void heif_context_add_compatible_brand(heif_context* ctx,
                                        heif_brand2 compatible_brand);

-//NEWAPI
 /**
  * Enable the unified ID namespace ('unif' brand).
  *
diff --git a/libheif/api/libheif/heif_image_handle.cc b/libheif/api/libheif/heif_image_handle.cc
index 68d36f6c..a8976d1d 100644
--- a/libheif/api/libheif/heif_image_handle.cc
+++ b/libheif/api/libheif/heif_image_handle.cc
@@ -278,68 +278,9 @@ const char* heif_image_handle_get_cmpd_component_type_uri(const heif_image_handl
 }


-// --- handle-side per-component getters
-//
-// These read from ImageItem::m_components (populated at parse time by
-// ImageItem::populate_component_descriptions). For unci images, the ids are
-// the same numerical values that heif_image_get_used_component_ids() will
-// report after decoding.
-
-uint32_t heif_image_handle_get_number_of_components(const heif_image_handle* handle)
-{
-  if (!handle) {
-    return 0;
-  }
-  return static_cast<uint32_t>(handle->image->get_component_descriptions().size());
-}
-
-
-void heif_image_handle_get_used_component_ids(const heif_image_handle* handle, uint32_t* out_component_ids)
-{
-  if (!handle || !out_component_ids) {
-    return;
-  }
-  const auto& comps = handle->image->get_component_descriptions();
-  for (size_t i = 0; i < comps.size(); i++) {
-    out_component_ids[i] = comps[i].component_id;
-  }
-}
-
-
-uint16_t heif_image_handle_get_component_type(const heif_image_handle* handle, uint32_t component_id)
-{
-  if (!handle) {
-    return 0;
-  }
-  if (auto* desc = handle->image->find_component_description(component_id)) {
-    return desc->component_type;
-  }
-  return 0;
-}
-
-
-int heif_image_handle_get_component_bits_per_pixel(const heif_image_handle* handle, uint32_t component_id)
-{
-  if (!handle) {
-    return -1;
-  }
-  if (auto* desc = handle->image->find_component_description(component_id)) {
-    return static_cast<int>(desc->bit_depth);
-  }
-  return -1;
-}
-
-
-heif_component_datatype heif_image_handle_get_component_datatype(const heif_image_handle* handle, uint32_t component_id)
-{
-  if (!handle) {
-    return heif_component_datatype_undefined;
-  }
-  if (auto* desc = handle->image->find_component_description(component_id)) {
-    return desc->datatype;
-  }
-  return heif_component_datatype_undefined;
-}
+// heif_image_handle_get_number_of_components, _get_used_component_ids,
+// _get_component_type, _get_component_bits_per_pixel and _get_component_datatype
+// live in heif_components.cc.


 int heif_image_handle_has_gimi_component_content_ids(const heif_image_handle* handle)
diff --git a/libheif/api/libheif/heif_image_handle.h b/libheif/api/libheif/heif_image_handle.h
index f3f4e642..d883bfcc 100644
--- a/libheif/api/libheif/heif_image_handle.h
+++ b/libheif/api/libheif/heif_image_handle.h
@@ -122,25 +122,21 @@ heif_context* heif_image_handle_get_context(const heif_image_handle* handle);
 LIBHEIF_API
 const char* heif_image_handle_get_gimi_content_id(const heif_image_handle* handle);

-//NEWAPI
 LIBHEIF_API
 void heif_image_handle_set_gimi_content_id(heif_image_handle* handle, const char* content_id);


 // --- cmpd component queries

-//NEWAPI
 // Returns the number of components in the cmpd box, or 0 if no cmpd property exists.
 LIBHEIF_API
 uint32_t heif_image_handle_get_number_of_cmpd_components(const heif_image_handle*);

-//NEWAPI
 // Returns the component_type for the given cmpd component index.
 // Returns 0 if out of range or no cmpd property.
 LIBHEIF_API
 uint16_t heif_image_handle_get_cmpd_component_type(const heif_image_handle*, uint32_t component_idx);

-//NEWAPI
 // Returns the component_type_uri for the given cmpd component index (component_type >= 0x8000).
 // Returns NULL if the component does not have a URI.
 // The returned string must be freed with heif_string_release().
@@ -150,19 +146,16 @@ const char* heif_image_handle_get_cmpd_component_type_uri(const heif_image_handl

 // --- GIMI component content IDs (handle-level)

-//NEWAPI
 // Returns non-zero (count of content IDs) if an ItemComponentContentIDProperty is set, 0 otherwise.
 LIBHEIF_API
 int heif_image_handle_has_gimi_component_content_ids(const heif_image_handle*);

-//NEWAPI
 // Returns the GIMI component content ID for the given component index.
 // Returns NULL if no ItemComponentContentIDProperty is set or index is out of range.
 // The returned string must be freed with heif_string_release().
 LIBHEIF_API
 const char* heif_image_handle_get_gimi_component_content_id(const heif_image_handle*, uint32_t component_idx);

-//NEWAPI
 // Set a GIMI component content ID for a single component.
 // If an ItemComponentContentIDProperty does not yet exist, one will be created.
 // The content IDs array is resized as needed (new entries default to empty).
diff --git a/libheif/api/libheif/heif_uncompressed.cc b/libheif/api/libheif/heif_uncompressed.cc
index 74f1be23..6ef18996 100644
--- a/libheif/api/libheif/heif_uncompressed.cc
+++ b/libheif/api/libheif/heif_uncompressed.cc
@@ -622,192 +622,8 @@ void heif_unci_image_parameters_release(heif_unci_image_parameters* params)
 }


-// --- id-based component access
-
-uint32_t heif_image_get_number_of_used_components(const heif_image* image)
-{
-  if (!image || !image->image) {
-    return 0;
-  }
-  return image->image->get_number_of_used_components();
-}
-
-
-void heif_image_get_used_component_ids(const heif_image* image, uint32_t* out_component_ids)
-{
-  if (!image || !image->image || !out_component_ids) {
-    return;
-  }
-
-  auto indices = image->image->get_used_component_ids();
-  for (size_t i = 0; i < indices.size(); i++) {
-    out_component_ids[i] = indices[i];
-  }
-}
-
-
-heif_channel heif_image_get_component_channel(const heif_image* image, uint32_t component_idx)
-{
-  if (!image || !image->image) {
-    return heif_channel_Y;
-  }
-  return image->image->get_component_channel(component_idx);
-}
-
-
-uint32_t heif_image_get_component_width(const heif_image* image, uint32_t component_idx)
-{
-  if (!image || !image->image) {
-    return 0;
-  }
-  return image->image->get_component_width(component_idx);
-}
-
-
-uint32_t heif_image_get_component_height(const heif_image* image, uint32_t component_idx)
-{
-  if (!image || !image->image) {
-    return 0;
-  }
-  return image->image->get_component_height(component_idx);
-}
-
-
-int heif_image_get_component_bits_per_pixel(const heif_image* image, uint32_t component_idx)
-{
-  if (!image || !image->image) {
-    return 0;
-  }
-  return image->image->get_component_bits_per_pixel(component_idx);
-}
-
-
-uint16_t heif_image_get_component_type(const heif_image* image, uint32_t component_idx)
-{
-  if (!image || !image->image) {
-    return 0;
-  }
-  return image->image->get_component_type(component_idx);
-}
-
-
-heif_component_datatype heif_image_get_component_datatype(const heif_image* image, uint32_t component_idx)
-{
-  if (!image || !image->image) {
-    return heif_component_datatype_undefined;
-  }
-  return image->image->get_component_datatype(component_idx);
-}
-
-
-heif_error heif_image_add_component(heif_image* image,
-                                    int width, int height,
-                                    uint16_t component_type,
-                                    heif_component_datatype datatype,
-                                    int bit_depth,
-                                    uint32_t* out_component_idx)
-{
-  if (!image || !image->image) {
-    return heif_error_null_pointer_argument;
-  }
-
-  auto result = image->image->add_component(width, height, component_type, datatype, bit_depth, nullptr);
-  if (!result) {
-    return result.error_struct(image->image.get());
-  }
-
-  if (out_component_idx) {
-    *out_component_idx = *result;
-  }
-
-  return heif_error_success;
-}
-
-
-const uint8_t* heif_image_get_component_readonly(const heif_image* image, uint32_t component_idx, size_t* out_stride)
-{
-  if (!image || !image->image) {
-    if (out_stride) *out_stride = 0;
-    return nullptr;
-  }
-  return image->image->get_component(component_idx, out_stride);
-}
-
-
-uint8_t* heif_image_get_component(heif_image* image, uint32_t component_idx, size_t* out_stride)
-{
-  if (!image || !image->image) {
-    if (out_stride) *out_stride = 0;
-    return nullptr;
-  }
-  return image->image->get_component(component_idx, out_stride);
-}
-
-
-// Typed accessors: convert the internal byte stride to element count for the
-// public API. libheif's allocator pads rows to a 16-byte boundary (see
-// pixelimage.cc), which is a multiple of sizeof(T) for every supported T
-// (<= 16 bytes), so the division is always exact.
-#define heif_image_get_component_X(name, type) \
-const type* heif_image_get_component_ ## name ## _readonly(const struct heif_image* image, \
-                                                            uint32_t component_idx, \
-                                                            size_t* out_row_elements) \
-{                                                            \
-  if (!image || !image->image) {                             \
-    if (out_row_elements) *out_row_elements = 0;             \
-    return nullptr;                                          \
-  }                                                          \
-  size_t byte_stride = 0;                                    \
-  const type* p = image->image->get_component_memory<type>(component_idx, &byte_stride); \
-  if (out_row_elements) *out_row_elements = byte_stride / sizeof(type); \
-  return p;                                                  \
-}                                                            \
-                                                             \
-type* heif_image_get_component_ ## name (struct heif_image* image, \
-                                         uint32_t component_idx,  \
-                                         size_t* out_row_elements) \
-{                                                            \
-  if (!image || !image->image) {                             \
-    if (out_row_elements) *out_row_elements = 0;             \
-    return nullptr;                                          \
-  }                                                          \
-  size_t byte_stride = 0;                                    \
-  type* p = image->image->get_component_memory<type>(component_idx, &byte_stride); \
-  if (out_row_elements) *out_row_elements = byte_stride / sizeof(type); \
-  return p;                                                  \
-}
-
-heif_image_get_component_X(uint16, uint16_t)
-heif_image_get_component_X(uint32, uint32_t)
-heif_image_get_component_X(uint64, uint64_t)
-heif_image_get_component_X(int8, int8_t)
-heif_image_get_component_X(int16, int16_t)
-heif_image_get_component_X(int32, int32_t)
-heif_image_get_component_X(int64, int64_t)
-heif_image_get_component_X(float32, float)
-heif_image_get_component_X(float64, double)
-heif_image_get_component_X(complex32, heif_complex32)
-heif_image_get_component_X(complex64, heif_complex64)
-
-
-heif_error heif_image_set_gimi_component_content_id(heif_image* image,
-                                                    uint32_t component_id,
-                                                    const char* content_id)
-{
-  if (image == nullptr || content_id == nullptr) {
-    return heif_error_null_pointer_argument;
-  }
-
-  auto* desc = image->image->find_component_description(component_id);
-  if (!desc) {
-    return {heif_error_Usage_error,
-            heif_suberror_Invalid_parameter_value,
-            "No component with the requested component_id exists."};
-  }
-  desc->gimi_content_id = content_id;
-
-  return heif_error_success;
-}
+// Multi-component access functions (heif_image_get/add_component_*,
+// heif_image_set_gimi_component_content_id) live in heif_components.cc.


 heif_error heif_context_add_empty_unci_image(heif_context* ctx,
diff --git a/libheif/api/libheif/heif_uncompressed.h b/libheif/api/libheif/heif_uncompressed.h
index 1e0f2298..a3ac8f65 100644
--- a/libheif/api/libheif/heif_uncompressed.h
+++ b/libheif/api/libheif/heif_uncompressed.h
@@ -22,6 +22,7 @@
 #define LIBHEIF_HEIF_UNCOMPRESSED_H

 #include "libheif/heif_uncompressed_types.h"
+#include "libheif/heif_components.h"
 #include "libheif/heif.h"

 #ifdef __cplusplus
@@ -37,7 +38,6 @@ extern "C" {

 // heif_uncompressed_component_type and heif_bayer_pattern_pixel are defined in heif_uncompressed_types.h.

-//NEWAPI
 // Set a Bayer / filter array pattern on an image.
 // The pattern is a 2D array of component indices with dimensions pattern_width x pattern_height.
 // The number of entries in patternPixels must be pattern_width * pattern_height.
@@ -52,13 +52,23 @@ heif_error heif_image_set_bayer_pattern(heif_image*,
                                         uint16_t pattern_height,
                                         const heif_bayer_pattern_pixel* patternPixels);

-//NEWAPI
+// Add a reference-only component to the image's component description table for use as
+// a Bayer pattern entry. The component is registered (its component_type appears in the
+// cmpd box) but carries no pixel plane of its own — the actual pixel data lives in the
+// single combined Bayer component (added with heif_image_add_component()).
+//
+// Use this for the per-cell colors that the Bayer pattern references (e.g. red, green,
+// blue) when those colors have no standalone plane. Pass the returned component_id in
+// heif_bayer_pattern_pixel::component_id of the patternPixels array given to
+// heif_image_set_bayer_pattern().
+//
+// component_type: one of heif_unci_component_type_* (e.g. _red, _green, _blue).
+// out_component_id: receives the minted component id. Must not be NULL.
 LIBHEIF_API
 heif_error heif_image_add_bayer_component(heif_image*,
                                           uint16_t component_type,
                                           uint32_t* out_component_id);

-//NEWAPI
 // Returns whether the image has a Bayer / filter array pattern.
 // If the image has a pattern, out_pattern_width and out_pattern_height are set.
 // Either output pointer may be NULL if the caller does not need that value.
@@ -68,7 +78,6 @@ int heif_image_get_bayer_pattern_size(const heif_image*,
                                       uint16_t* out_pattern_width,
                                       uint16_t* out_pattern_height);

-//NEWAPI
 // Get the Bayer / filter array pattern pixels.
 // The caller must provide an array large enough for pattern_width * pattern_height entries
 // (use heif_image_get_bayer_pattern_size() to query the dimensions first).
@@ -84,17 +93,14 @@ heif_error heif_image_get_bayer_pattern(const heif_image*,
 // On the wire this is the IEEE 754 bit pattern 0xFFFFFFFF (a signaling NaN).
 // Test with heif_polarization_angle_is_no_filter() below, or with isnan()/std::isnan().

-//NEWAPI
 // Returns a float with the 0xFFFFFFFF bit pattern (NaN) representing "no polarization filter".
 LIBHEIF_API
 float heif_polarization_angle_no_filter(void);

-//NEWAPI
 // Returns non-zero if the given angle has the "no filter" bit pattern (0xFFFFFFFF).
 LIBHEIF_API
 int heif_polarization_angle_is_no_filter(float angle);

-//NEWAPI
 // Add a polarization pattern to an image.
 // component_indices: array of component indices this pattern applies to (may be NULL if num_component_indices == 0,
 //                    meaning the pattern applies to all components).
@@ -109,12 +115,10 @@ heif_error heif_image_add_polarization_pattern(heif_image*,
                                                uint16_t pattern_height,
                                                const float* polarization_angles);

-//NEWAPI
 // Returns the number of polarization patterns on this image (0 if none).
 LIBHEIF_API
 int heif_image_get_number_of_polarization_patterns(const heif_image*);

-//NEWAPI
 // Get the sizes/dimensions of a polarization pattern (to allocate arrays for the data query).
 LIBHEIF_API
 heif_error heif_image_get_polarization_pattern_info(const heif_image*,
@@ -123,7 +127,6 @@ heif_error heif_image_get_polarization_pattern_info(const heif_image*,
                                                     uint16_t* out_pattern_width,
                                                     uint16_t* out_pattern_height);

-//NEWAPI
 // Get the actual data of a polarization pattern.
 // Caller must provide pre-allocated arrays:
 //   out_component_indices: num_component_indices entries (may be NULL if num_component_indices == 0)
@@ -134,7 +137,6 @@ heif_error heif_image_get_polarization_pattern_data(const heif_image*,
                                                     uint32_t* out_component_indices,
                                                     float* out_polarization_angles);

-//NEWAPI
 // Find the polarization pattern index that applies to a given component index.
 // Returns the pattern index (>= 0), or -1 if no pattern matches.
 // A pattern with an empty component list (component_count == 0) matches all components.
@@ -147,7 +149,6 @@ int heif_image_get_polarization_pattern_index_for_component(const heif_image*,

 // struct heif_bad_pixel is defined in heif_uncompressed_types.h.

-//NEWAPI
 // Add a sensor bad pixels map to an image.
 // component_indices: array of component indices this map applies to (may be NULL if num_component_indices == 0,
 //                    meaning the map applies to all components).
@@ -164,12 +165,10 @@ heif_error heif_image_add_sensor_bad_pixels_map(heif_image*,
                                                  uint32_t num_bad_pixels,
                                                  const heif_bad_pixel* bad_pixels);

-//NEWAPI
 // Returns the number of sensor bad pixels maps on this image (0 if none).
 LIBHEIF_API
 int heif_image_get_number_of_sensor_bad_pixels_maps(const heif_image*);

-//NEWAPI
 // Get the sizes of a sensor bad pixels map (to allocate arrays for the data query).
 LIBHEIF_API
 heif_error heif_image_get_sensor_bad_pixels_map_info(const heif_image*,
@@ -180,7 +179,6 @@ heif_error heif_image_get_sensor_bad_pixels_map_info(const heif_image*,
                                                       uint32_t* out_num_bad_columns,
                                                       uint32_t* out_num_bad_pixels);

-//NEWAPI
 // Get the actual data of a sensor bad pixels map.
 // Caller must provide pre-allocated arrays:
 //   out_component_indices: num_component_indices entries (may be NULL if num_component_indices == 0)
@@ -198,7 +196,6 @@ heif_error heif_image_get_sensor_bad_pixels_map_data(const heif_image*,

 // --- Sensor non-uniformity correction (ISO 23001-17, Section 6.1.6)

-//NEWAPI
 // Add a sensor non-uniformity correction table to an image.
 // component_indices: array of component indices this NUC applies to (may be NULL if num_component_indices == 0,
 //                    meaning it applies to all components).
@@ -215,12 +212,10 @@ heif_error heif_image_add_sensor_nuc(heif_image*,
                                       const float* nuc_gains,
                                       const float* nuc_offsets);

-//NEWAPI
 // Returns the number of sensor NUC tables on this image (0 if none).
 LIBHEIF_API
 int heif_image_get_number_of_sensor_nucs(const heif_image*);

-//NEWAPI
 // Get the sizes of a sensor NUC table (to allocate arrays for the data query).
 LIBHEIF_API
 heif_error heif_image_get_sensor_nuc_info(const heif_image*,
@@ -230,7 +225,6 @@ heif_error heif_image_get_sensor_nuc_info(const heif_image*,
                                            uint32_t* out_image_width,
                                            uint32_t* out_image_height);

-//NEWAPI
 // Get the actual data of a sensor NUC table.
 // Caller must provide pre-allocated arrays:
 //   out_component_indices: num_component_indices entries (may be NULL if num_component_indices == 0)
@@ -248,18 +242,15 @@ heif_error heif_image_get_sensor_nuc_data(const heif_image*,

 // --- Chroma sample location (ISO 23001-17, Section 6.1.4)

-//NEWAPI
 // Set the chroma sample location on an image.
 // chroma_location must be in the range 0-6 (see heif_chroma420_sample_location).
 LIBHEIF_API
 heif_error heif_image_set_chroma_location(heif_image*, uint8_t chroma_location);

-//NEWAPI
 // Returns non-zero if the image has a chroma sample location set.
 LIBHEIF_API
 int heif_image_has_chroma_location(const heif_image*);

-//NEWAPI
 // Returns the chroma sample location (0-6), or 0 if none is set.
 LIBHEIF_API
 uint8_t heif_image_get_chroma_location(const heif_image*);
@@ -313,209 +304,10 @@ heif_error heif_context_add_empty_unci_image(heif_context* ctx,
                                              const heif_image* prototype,
                                              heif_image_handle** out_unci_image_handle);

-// heif_channel_datatype, heif_complex32, heif_complex64 are defined in heif_uncompressed_types.h.
-
-// --- index-based component access (for ISO 23001-17 multi-component images)
-
-//NEWAPI
-// Returns the number of components that have pixel data (planes) in this image.
-LIBHEIF_API
-uint32_t heif_image_get_number_of_used_components(const heif_image*);
-
-//NEWAPI
-// Fills `out_component_indices` with the valid component indices.
-// The caller must allocate an array of at least heif_image_get_number_of_used_components() elements.
-LIBHEIF_API
-void heif_image_get_used_component_ids(const heif_image*, uint32_t* out_component_ids);
-
-//NEWAPI
-LIBHEIF_API
-heif_channel heif_image_get_component_channel(const heif_image*, uint32_t component_idx);
-
-//NEWAPI
-LIBHEIF_API
-uint32_t heif_image_get_component_width(const heif_image*, uint32_t component_idx);
-
-//NEWAPI
-LIBHEIF_API
-uint32_t heif_image_get_component_height(const heif_image*, uint32_t component_idx);
-
-//NEWAPI
-LIBHEIF_API
-int heif_image_get_component_bits_per_pixel(const heif_image*, uint32_t component_idx);
-
-//NEWAPI
-LIBHEIF_API
-uint16_t heif_image_get_component_type(const heif_image*, uint32_t component_idx);
-
-//NEWAPI
-// Returns the datatype (unsigned/signed integer, floating point, or complex
-// number) of the given component.
-LIBHEIF_API
-heif_component_datatype heif_image_get_component_datatype(const heif_image*, uint32_t component_idx);
-
-// --- ID-based component access via heif_image_handle (before decoding)
-//
-// These let the caller introspect a unci image's components without decoding
-// any tile. They return 0 / -1 / heif_component_datatype_undefined for
-// non-unci images or unknown component IDs.
-//
-// The component IDs returned here match the IDs that
-// heif_image_get_used_component_ids() will report after the same image is
-// decoded, so the same numerical id can be used to address a component on
-// either side of the API.
+// Multi-component access functions (heif_image_get/add_component_*,
+// heif_image_handle_get_component_*, heif_image_set_gimi_component_content_id)
+// live in heif_components.h, which is included above.

-//NEWAPI
-LIBHEIF_API
-uint32_t heif_image_handle_get_number_of_components(const heif_image_handle*);
-
-//NEWAPI
-// Fills `out_component_ids` with the valid component IDs.
-// The caller must allocate an array of at least
-// heif_image_handle_get_number_of_components() elements.
-LIBHEIF_API
-void heif_image_handle_get_used_component_ids(const heif_image_handle*, uint32_t* out_component_ids);
-
-//NEWAPI
-LIBHEIF_API
-uint16_t heif_image_handle_get_component_type(const heif_image_handle*, uint32_t component_id);
-
-//NEWAPI
-LIBHEIF_API
-int heif_image_handle_get_component_bits_per_pixel(const heif_image_handle*, uint32_t component_id);
-
-//NEWAPI
-LIBHEIF_API
-heif_component_datatype heif_image_handle_get_component_datatype(const heif_image_handle*, uint32_t component_id);
-
-// TODO
-//LIBHEIF_API
-//heif_error heif_image_get_component_indices_of_interleaved_channel(const heif_image* image, uint32_t* component_indices, uint8_t* nComponents_in_out);
-
-//NEWAPI
-LIBHEIF_API
-heif_error heif_image_add_component(heif_image* image,
-                                    int width, int height,
-                                    uint16_t component_type,
-                                    heif_component_datatype datatype,
-                                    int bit_depth,
-                                    uint32_t* out_component_idx);
-
-// Untyped uint8 component data getters: stride is in BYTES per row.
-//NEWAPI
-LIBHEIF_API
-const uint8_t* heif_image_get_component_readonly(const heif_image*, uint32_t component_idx, size_t* out_stride);
-
-//NEWAPI
-LIBHEIF_API
-uint8_t* heif_image_get_component(heif_image*, uint32_t component_idx, size_t* out_stride);
-
-// Typed component data getters: `out_row_elements` is the number of T elements
-// per row, not bytes. Index with `data[y * row_elements + x]` (no casts, no
-// sizeof). libheif allocates rows with element-aligned padding, so this count
-// is always exact for the named type T.
-//NEWAPI
-LIBHEIF_API
-const uint16_t* heif_image_get_component_uint16_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-uint16_t* heif_image_get_component_uint16(heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-const uint32_t* heif_image_get_component_uint32_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-uint32_t* heif_image_get_component_uint32(heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-const uint64_t* heif_image_get_component_uint64_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-uint64_t* heif_image_get_component_uint64(heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-const int8_t* heif_image_get_component_int8_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-int8_t* heif_image_get_component_int8(heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-const int16_t* heif_image_get_component_int16_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-int16_t* heif_image_get_component_int16(heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-const int32_t* heif_image_get_component_int32_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-int32_t* heif_image_get_component_int32(heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-const int64_t* heif_image_get_component_int64_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-int64_t* heif_image_get_component_int64(heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-const float* heif_image_get_component_float32_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-float* heif_image_get_component_float32(heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-const double* heif_image_get_component_float64_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-double* heif_image_get_component_float64(heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-const heif_complex32* heif_image_get_component_complex32_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-heif_complex32* heif_image_get_component_complex32(heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-const heif_complex64* heif_image_get_component_complex64_readonly(const heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-//NEWAPI
-LIBHEIF_API
-heif_complex64* heif_image_get_component_complex64(heif_image*, uint32_t component_idx, size_t* out_row_elements);
-
-
-// --- GIMI component content IDs (set before encoding)
-
-//NEWAPI
-// Set a GIMI component content ID for the component with the given
-// component_id (as minted by heif_image_add_component / returned via the
-// component access API). Pass an empty string to clear a previously set id.
-// Returns an error if no component with this id exists on the image.
-// The collected ids are written into an ItemComponentContentIDProperty box
-// during encoding.
-LIBHEIF_API
-heif_error heif_image_set_gimi_component_content_id(heif_image*,
-                                                    uint32_t component_id,
-                                                    const char* content_id);

 #ifdef __cplusplus
 }
diff --git a/libheif/api/libheif/heif_uncompressed_types.h b/libheif/api/libheif/heif_uncompressed_types.h
index 73274519..8de23297 100644
--- a/libheif/api/libheif/heif_uncompressed_types.h
+++ b/libheif/api/libheif/heif_uncompressed_types.h
@@ -23,13 +23,14 @@

 #include <stdint.h>

+#include "libheif/heif_components.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif

 // --- ISO 23001-17 component types (Table 1)

-//NEWAPI
 typedef enum heif_unci_component_type
 {
   heif_unci_component_type_monochrome = 0,
@@ -54,7 +55,6 @@ typedef enum heif_unci_component_type

 // --- Bayer / filter array pattern

-//NEWAPI
 typedef struct heif_bayer_pattern_pixel
 {
   uint32_t component_id;
@@ -64,13 +64,11 @@ typedef struct heif_bayer_pattern_pixel

 // --- Sensor bad pixels map (ISO 23001-17, Section 6.1.7)

-//NEWAPI
 struct heif_bad_pixel { uint32_t row; uint32_t column; };


 // --- Chroma sample location (ISO 23091-2 / ITU-T H.273 + ISO 23001-17)

-//NEWAPI
 typedef enum heif_chroma420_sample_location {
   // values 0-5 according to ISO 23091-2 / ITU-T H.273
   heif_chroma420_sample_location_00_05 = 0,
@@ -119,33 +117,9 @@ typedef struct heif_unci_image_parameters
 } heif_unci_image_parameters;


-// --- pixel datatype support
-//
-// The numeric values are aligned with the ISO/IEC 23001-17 Table 2
-// component_format byte (used by the uncC box of the uncompressed codec).
-// This is an internal convenience and should not be relied upon.
+// heif_component_datatype, heif_complex32, heif_complex64 are defined in
+// heif_components.h (included above).

-//NEWAPI
-typedef enum heif_component_datatype
-{
-  heif_component_datatype_unsigned_integer = 0,
-  heif_component_datatype_floating_point   = 1,
-  heif_component_datatype_complex_number   = 2,
-  heif_component_datatype_signed_integer   = 3,
-  heif_component_datatype_undefined        = 0xFF
-} heif_component_datatype;
-
-//NEWAPI
-typedef struct heif_complex32
-{
-  float real, imaginary;
-} heif_complex32;
-
-//NEWAPI
-typedef struct heif_complex64
-{
-  double real, imaginary;
-} heif_complex64;

 #ifdef __cplusplus
 }