pylibheif 1.21.2__cp312-cp312-manylinux_2_28_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. include/libheif/heif.h +41 -0
  2. include/libheif/heif_aux_images.h +182 -0
  3. include/libheif/heif_brands.h +376 -0
  4. include/libheif/heif_color.h +363 -0
  5. include/libheif/heif_context.h +329 -0
  6. include/libheif/heif_cxx.h +1390 -0
  7. include/libheif/heif_decoding.h +172 -0
  8. include/libheif/heif_encoding.h +395 -0
  9. include/libheif/heif_entity_groups.h +60 -0
  10. include/libheif/heif_error.h +304 -0
  11. include/libheif/heif_image.h +355 -0
  12. include/libheif/heif_image_handle.h +129 -0
  13. include/libheif/heif_items.h +260 -0
  14. include/libheif/heif_library.h +219 -0
  15. include/libheif/heif_metadata.h +136 -0
  16. include/libheif/heif_plugin.h +378 -0
  17. include/libheif/heif_properties.h +235 -0
  18. include/libheif/heif_regions.h +868 -0
  19. include/libheif/heif_security.h +107 -0
  20. include/libheif/heif_sequences.h +644 -0
  21. include/libheif/heif_tai_timestamps.h +202 -0
  22. include/libheif/heif_text.h +161 -0
  23. include/libheif/heif_tiling.h +137 -0
  24. include/libheif/heif_uncompressed.h +109 -0
  25. include/libheif/heif_version.h +38 -0
  26. lib64/cmake/libheif/libheif-config-release.cmake +19 -0
  27. lib64/cmake/libheif/libheif-config-version.cmake +83 -0
  28. lib64/cmake/libheif/libheif-config.cmake +108 -0
  29. lib64/libheif.a +0 -0
  30. lib64/pkgconfig/libheif.pc +15 -0
  31. pylibheif-1.21.2.dist-info/METADATA +409 -0
  32. pylibheif-1.21.2.dist-info/RECORD +40 -0
  33. pylibheif-1.21.2.dist-info/WHEEL +5 -0
  34. pylibheif-1.21.2.dist-info/licenses/LICENSE +165 -0
  35. pylibheif.cpython-312-x86_64-linux-gnu.so +0 -0
  36. pylibheif.libs/libaom-dfa445bf.so.3.6.1 +0 -0
  37. pylibheif.libs/libde265-75ee619c.so.0.1.8 +0 -0
  38. pylibheif.libs/libnuma-3387f5e3.so.1.0.0 +0 -0
  39. pylibheif.libs/libopenjp2-88dcb7ba.so.2.4.0 +0 -0
  40. pylibheif.libs/libx265-da180509.so.176 +0 -0
@@ -0,0 +1,868 @@
1
+ /*
2
+ * HEIF codec.
3
+ * Copyright (c) 2023 Dirk Farin <dirk.farin@gmail.com>
4
+ * Copyright (c) 2023 Brad Hards <bradh@frogmouth.net>
5
+ *
6
+ * This file is part of libheif.
7
+ *
8
+ * libheif is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as
10
+ * published by the Free Software Foundation, either version 3 of
11
+ * the License, or (at your option) any later version.
12
+ *
13
+ * libheif is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with libheif. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+ #ifndef LIBHEIF_HEIF_REGIONS_H
23
+ #define LIBHEIF_HEIF_REGIONS_H
24
+
25
+ #include "heif_image_handle.h"
26
+ #include "heif_library.h"
27
+ #include "heif_error.h"
28
+
29
+ #ifdef __cplusplus
30
+ extern "C" {
31
+ #endif
32
+
33
+ // --- region items and annotations
34
+
35
+ // See ISO/IEC 23008-12:2022 Section 6.10 "Region items and region annotations"
36
+
37
+ typedef struct heif_region_item heif_region_item;
38
+
39
+ /**
40
+ * Region type.
41
+ *
42
+ * Each region item will contain zero or more regions, which may have different geometry or
43
+ * mask representations.
44
+ */
45
+ typedef enum heif_region_type
46
+ {
47
+ /**
48
+ * Point geometry.
49
+ *
50
+ * The region is represented by a single point.
51
+ */
52
+ heif_region_type_point = 0,
53
+
54
+ /**
55
+ * Rectangle geometry.
56
+ *
57
+ * The region is represented by a top left position, and a size defined
58
+ * by a width and height. All of the interior points and the edge are
59
+ * part of the region.
60
+ */
61
+ heif_region_type_rectangle = 1,
62
+
63
+ /**
64
+ * Ellipse geometry.
65
+ *
66
+ * The region is represented by a centre point, and radii in the X and
67
+ * Y directions. All of the interior points and the edge are part of the
68
+ * region.
69
+ */
70
+ heif_region_type_ellipse = 2,
71
+
72
+ /**
73
+ * Polygon geometry.
74
+ *
75
+ * The region is represented by a sequence of points, which is considered
76
+ * implicitly closed. All of the interior points and the edge are part
77
+ * of the region.
78
+ */
79
+ heif_region_type_polygon = 3,
80
+
81
+ /**
82
+ * Reference mask.
83
+ *
84
+ * The region geometry is described by the pixels in another image item,
85
+ * which has a item reference of type `mask` from the region item to the
86
+ * image item containing the mask.
87
+ *
88
+ * The image item containing the mask is one of:
89
+ *
90
+ * - a mask item (see ISO/IEC 23008-12:2022 Section 6.10.2), or a derived
91
+ * image from a mask item
92
+ *
93
+ * - an image item in monochrome format (4:0:0 chroma)
94
+ *
95
+ * - an image item in colour format with luma and chroma planes (e.g. 4:2:0)
96
+ *
97
+ * If the pixel value is equal to the minimum sample value (e.g. 0 for unsigned
98
+ * integer), the pixel is not part of the region. If the pixel value is equal
99
+ * to the maximum sample value (e.g. 255 for 8 bit unsigned integer), the pixel
100
+ * is part of the region. If the pixel value is between the minimum sample value
101
+ * and maximum sample value, the pixel value represents an (application defined)
102
+ * probability that the pixel is part of the region, where higher pixel values
103
+ * correspond to higher probability values.
104
+ */
105
+ heif_region_type_referenced_mask = 4,
106
+
107
+ /**
108
+ * Inline mask.
109
+ *
110
+ * The region geometry is described by a sequence of bits stored in inline
111
+ * in the region, one bit per pixel. If the bit value is `1`, the pixel is
112
+ * part of the region. If the bit value is `0`, the pixel is not part of the
113
+ * region.
114
+ */
115
+ heif_region_type_inline_mask = 5,
116
+
117
+ /**
118
+ * Polyline geometry.
119
+ *
120
+ * The region is represented by a sequence of points, which are not
121
+ * considered to form a closed surface. Only the edge is part of the region.
122
+ */
123
+ heif_region_type_polyline = 6
124
+ } heif_region_type;
125
+
126
+ typedef struct heif_region heif_region;
127
+
128
+ /**
129
+ * Get the number of region items that are attached to an image.
130
+ *
131
+ * @param image_handle the image handle for the image to query.
132
+ * @return the number of region items, which can be zero.
133
+ */
134
+ LIBHEIF_API
135
+ int heif_image_handle_get_number_of_region_items(const heif_image_handle* image_handle);
136
+
137
+ /**
138
+ * Get the region item identifiers for the region items attached to an image.
139
+ *
140
+ * Possible usage (in C++):
141
+ * @code
142
+ * int numRegionItems = heif_image_handle_get_number_of_region_items(handle);
143
+ * if (numRegionItems > 0) {
144
+ * std::vector<heif_item_id> region_item_ids(numRegionItems);
145
+ * heif_image_handle_get_list_of_region_item_ids(handle, region_item_ids.data(), numRegionItems);
146
+ * // use region item ids
147
+ * }
148
+ * @endcode
149
+ *
150
+ * @param image_handle the image handle for the parent image to query
151
+ * @param region_item_ids_array array to put the item identifiers into
152
+ * @param max_count the maximum number of region identifiers
153
+ * @return the number of region item identifiers that were returned.
154
+ */
155
+ LIBHEIF_API
156
+ int heif_image_handle_get_list_of_region_item_ids(const heif_image_handle* image_handle,
157
+ heif_item_id* region_item_ids_array,
158
+ int max_count);
159
+
160
+ /**
161
+ * Get the region item.
162
+ *
163
+ * Caller is responsible for release of the output heif_region_item with heif_region_item_release().
164
+ *
165
+ * @param context the context to get the region item from, usually from a file operation
166
+ * @param region_item_id the identifier for the region item
167
+ * @param out pointer to pointer to the resulting region item
168
+ * @return heif_error_ok on success, or an error value indicating the problem
169
+ */
170
+ LIBHEIF_API
171
+ heif_error heif_context_get_region_item(const heif_context* context,
172
+ heif_item_id region_item_id,
173
+ heif_region_item** out);
174
+
175
+ /**
176
+ * Get the item identifier for a region item.
177
+ *
178
+ * @param region_item the region item to query
179
+ * @return the region item identifier (or 0 if the region_item is null)
180
+ */
181
+ LIBHEIF_API
182
+ heif_item_id heif_region_item_get_id(heif_region_item* region_item);
183
+
184
+ /**
185
+ * Release a region item.
186
+ *
187
+ * This should be called on items from heif_context_get_region_item().
188
+ *
189
+ * @param region_item the item to release.
190
+ */
191
+ LIBHEIF_API
192
+ void heif_region_item_release(heif_region_item* region_item);
193
+
194
+ /**
195
+ * Get the reference size for a region item.
196
+ *
197
+ * The reference size specifies the coordinate space used for the region items.
198
+ * When the reference size does not match the image size, the regions need to be
199
+ * scaled to correspond.
200
+ *
201
+ * @param out_width the return value for the reference width (before any transformation)
202
+ * @param out_height the return value for the reference height (before any transformation)
203
+ */
204
+ LIBHEIF_API
205
+ void heif_region_item_get_reference_size(heif_region_item*, uint32_t* out_width, uint32_t* out_height);
206
+
207
+ /**
208
+ * Get the number of regions within a region item.
209
+ *
210
+ * @param region_item the region item to query.
211
+ * @return the number of regions
212
+ */
213
+ LIBHEIF_API
214
+ int heif_region_item_get_number_of_regions(const heif_region_item* region_item);
215
+
216
+ /**
217
+ * Get the regions that are part of a region item.
218
+ *
219
+ * Caller is responsible for releasing the returned `heif_region` objects, using heif_region_release()
220
+ * on each region, or heif_region_release_many() on the returned array.
221
+ *
222
+ * Possible usage (in C++):
223
+ * @code
224
+ * int num_regions = heif_image_handle_get_number_of_regions(region_item);
225
+ * if (num_regions > 0) {
226
+ * std::vector<heif_region*> regions(num_regions);
227
+ * int n = heif_region_item_get_list_of_regions(region_item, regions.data(), (int)regions.size());
228
+ * // use regions
229
+ * heif_region_release_many(regions.data(), n);
230
+ * }
231
+ * @endcode
232
+ *
233
+ * @param region_item the region_item to query
234
+ * @param out_regions_array array to put the region pointers into
235
+ * @param max_count the maximum number of regions, which needs to correspond to the size of the out_regions_array
236
+ * @return the number of regions that were returned.
237
+ */
238
+ LIBHEIF_API
239
+ int heif_region_item_get_list_of_regions(const heif_region_item* region_item,
240
+ heif_region** out_regions_array,
241
+ int max_count);
242
+
243
+ /**
244
+ * Release a region.
245
+ *
246
+ * This should be called on regions from heif_region_item_get_list_of_regions().
247
+ *
248
+ * @param region the region to release.
249
+ *
250
+ * \sa heif_region_release_many() to release the whole list
251
+ */
252
+ LIBHEIF_API
253
+ void heif_region_release(const heif_region* region);
254
+
255
+ /**
256
+ * Release a list of regions.
257
+ *
258
+ * This should be called on the list of regions from heif_region_item_get_list_of_regions().
259
+ *
260
+ * @param regions_array the regions to release.
261
+ * @param num_items the number of items in the array
262
+ *
263
+ * \sa heif_region_release() to release a single region
264
+ */
265
+ LIBHEIF_API
266
+ void heif_region_release_many(const heif_region* const* regions_array, int num_items);
267
+
268
+ /**
269
+ * Get the region type for a specified region.
270
+ *
271
+ * @param region the region to query
272
+ * @return the corresponding region type as an enumeration value
273
+ */
274
+ LIBHEIF_API
275
+ enum heif_region_type heif_region_get_type(const heif_region* region);
276
+
277
+ // When querying the region geometry, there is a version without and a version with "_transformed" suffix.
278
+ // The version without returns the coordinates in the reference coordinate space.
279
+ // The version with "_transformed" suffix give the coordinates in pixels after all transformative properties have been applied.
280
+
281
+ /**
282
+ * Get the values for a point region.
283
+ *
284
+ * This returns the coordinates in the reference coordinate space (from the parent region item).
285
+ *
286
+ * @param region the region to query, which must be of type #heif_region_type_point.
287
+ * @param out_x the X coordinate, where 0 is the left-most column.
288
+ * @param out_y the Y coordinate, where 0 is the top-most row.
289
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
290
+ *
291
+ * \sa heif_region_get_point_transformed() for a version in pixels after all transformative properties have been applied.
292
+ */
293
+ LIBHEIF_API
294
+ heif_error heif_region_get_point(const heif_region* region, int32_t* out_x, int32_t* out_y);
295
+
296
+ /**
297
+ * Get the transformed values for a point region.
298
+ *
299
+ * This returns the coordinates in pixels after all transformative properties have been applied.
300
+ *
301
+ * @param region the region to query, which must be of type #heif_region_type_point.
302
+ * @param image_id the identifier for the image to transform / scale the region to
303
+ * @param out_x the X coordinate, where 0 is the left-most column.
304
+ * @param out_y the Y coordinate, where 0 is the top-most row.
305
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
306
+ *
307
+ * \sa heif_region_get_point() for a version that returns the values in the reference coordinate space.
308
+ */
309
+ LIBHEIF_API
310
+ heif_error heif_region_get_point_transformed(const heif_region* region, heif_item_id image_id, double* out_x, double* out_y);
311
+
312
+ /**
313
+ * Get the values for a rectangle region.
314
+ *
315
+ * This returns the values in the reference coordinate space (from the parent region item).
316
+ * The rectangle is represented by a top left corner position, and a size defined
317
+ * by a width and height. All of the interior points and the edge are
318
+ * part of the region.
319
+ *
320
+ * @param region the region to query, which must be of type #heif_region_type_rectangle.
321
+ * @param out_x the X coordinate for the top left corner, where 0 is the left-most column.
322
+ * @param out_y the Y coordinate for the top left corner, where 0 is the top-most row.
323
+ * @param out_width the width of the rectangle
324
+ * @param out_height the height of the rectangle
325
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
326
+ *
327
+ * \sa heif_region_get_rectangle_transformed() for a version in pixels after all transformative properties have been applied.
328
+ */
329
+ LIBHEIF_API
330
+ heif_error heif_region_get_rectangle(const heif_region* region,
331
+ int32_t* out_x, int32_t* out_y,
332
+ uint32_t* out_width, uint32_t* out_height);
333
+
334
+ /**
335
+ * Get the transformed values for a rectangle region.
336
+ *
337
+ * This returns the coordinates in pixels after all transformative properties have been applied.
338
+ * The rectangle is represented by a top left corner position, and a size defined
339
+ * by a width and height. All of the interior points and the edge are
340
+ * part of the region.
341
+ *
342
+ * @param region the region to query, which must be of type #heif_region_type_rectangle.
343
+ * @param image_id the identifier for the image to transform / scale the region to
344
+ * @param out_x the X coordinate for the top left corner, where 0 is the left-most column.
345
+ * @param out_y the Y coordinate for the top left corner, where 0 is the top-most row.
346
+ * @param out_width the width of the rectangle
347
+ * @param out_height the height of the rectangle
348
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
349
+ *
350
+ * \sa heif_region_get_rectangle() for a version that returns the values in the reference coordinate space.
351
+ */
352
+ LIBHEIF_API
353
+ heif_error heif_region_get_rectangle_transformed(const heif_region* region,
354
+ heif_item_id image_id,
355
+ double* out_x, double* out_y,
356
+ double* out_width, double* out_height);
357
+
358
+ /**
359
+ * Get the values for an ellipse region.
360
+ *
361
+ * This returns the values in the reference coordinate space (from the parent region item).
362
+ * The ellipse is represented by a centre position, and a size defined
363
+ * by radii in the X and Y directions. All of the interior points and the edge are
364
+ * part of the region.
365
+ *
366
+ * @param region the region to query, which must be of type #heif_region_type_ellipse.
367
+ * @param out_x the X coordinate for the centre point, where 0 is the left-most column.
368
+ * @param out_y the Y coordinate for the centre point, where 0 is the top-most row.
369
+ * @param out_radius_x the radius value in the X direction.
370
+ * @param out_radius_y the radius value in the Y direction
371
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
372
+ *
373
+ * \sa heif_region_get_ellipse_transformed() for a version in pixels after all transformative properties have been applied.
374
+ */
375
+ LIBHEIF_API
376
+ heif_error heif_region_get_ellipse(const heif_region* region,
377
+ int32_t* out_x, int32_t* out_y,
378
+ uint32_t* out_radius_x, uint32_t* out_radius_y);
379
+
380
+
381
+ /**
382
+ * Get the transformed values for an ellipse region.
383
+ *
384
+ * This returns the coordinates in pixels after all transformative properties have been applied.
385
+ * The ellipse is represented by a centre position, and a size defined
386
+ * by radii in the X and Y directions. All of the interior points and the edge are
387
+ * part of the region.
388
+ *
389
+ * @param region the region to query, which must be of type #heif_region_type_ellipse.
390
+ * @param image_id the identifier for the image to transform / scale the region to
391
+ * @param out_x the X coordinate for the centre point, where 0 is the left-most column.
392
+ * @param out_y the Y coordinate for the centre point, where 0 is the top-most row.
393
+ * @param out_radius_x the radius value in the X direction.
394
+ * @param out_radius_y the radius value in the Y direction
395
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
396
+ *
397
+ * \sa heif_region_get_ellipse() for a version that returns the values in the reference coordinate space.
398
+ */
399
+ LIBHEIF_API
400
+ heif_error heif_region_get_ellipse_transformed(const heif_region* region,
401
+ heif_item_id image_id,
402
+ double* out_x, double* out_y,
403
+ double* out_radius_x, double* out_radius_y);
404
+
405
+ /**
406
+ * Get the number of points in a polygon.
407
+ *
408
+ * @param region the region to query, which must be of type #heif_region_type_polygon
409
+ * @return the number of points, or -1 on error.
410
+ */
411
+ LIBHEIF_API
412
+ int heif_region_get_polygon_num_points(const heif_region* region);
413
+
414
+ /**
415
+ * Get the points in a polygon region.
416
+ *
417
+ * This returns the values in the reference coordinate space (from the parent region item).
418
+ *
419
+ * A polygon is a sequence of points that form a closed shape. The first point does
420
+ * not need to be repeated as the last point. All of the interior points and the edge are
421
+ * part of the region.
422
+ * The points are returned as pairs of X,Y coordinates, in the order X<sub>1</sub>,
423
+ * Y<sub>1</sub>, X<sub>2</sub>, Y<sub>2</sub>, ..., X<sub>n</sub>, Y<sub>n</sub>.
424
+ *
425
+ * @param region the region to query, which must be of type #heif_region_type_polygon
426
+ * @param out_pts_array the array to return the points in, which must have twice as many entries as there are points
427
+ * in the polygon.
428
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
429
+ *
430
+ * \sa heif_region_get_polygon_points_transformed() for a version in pixels after all transformative properties have been applied.
431
+ */
432
+ LIBHEIF_API
433
+ heif_error heif_region_get_polygon_points(const heif_region* region,
434
+ int32_t* out_pts_array);
435
+
436
+ /**
437
+ * Get the transformed points in a polygon region.
438
+ *
439
+ * This returns the coordinates in pixels after all transformative properties have been applied.
440
+ *
441
+ * A polygon is a sequence of points that form a closed shape. The first point does
442
+ * not need to be repeated as the last point. All of the interior points and the edge are
443
+ * part of the region.
444
+ * The points are returned as pairs of X,Y coordinates, in the order X<sub>1</sub>,
445
+ * Y<sub>1</sub>, X<sub>2</sub>, Y<sub>2</sub>, ..., X<sub>n</sub>, Y<sub>n</sub>.
446
+ *
447
+ * @param region the region to query, which must be of type #heif_region_type_polygon
448
+ * @param image_id the identifier for the image to transform / scale the region to
449
+ * @param out_pts_array the array to return the points in, which must have twice as many entries as there are points
450
+ * in the polygon.
451
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
452
+ *
453
+ * \sa heif_region_get_polygon_points() for a version that returns the values in the reference coordinate space.
454
+ */
455
+ LIBHEIF_API
456
+ heif_error heif_region_get_polygon_points_transformed(const heif_region* region,
457
+ heif_item_id image_id,
458
+ double* out_pts_array);
459
+ /**
460
+ * Get the number of points in a polyline.
461
+ *
462
+ * @param region the region to query, which must be of type #heif_region_type_polyline
463
+ * @return the number of points, or -1 on error.
464
+ */
465
+ LIBHEIF_API
466
+ int heif_region_get_polyline_num_points(const heif_region* region);
467
+
468
+ /**
469
+ * Get the points in a polyline region.
470
+ *
471
+ * This returns the values in the reference coordinate space (from the parent region item).
472
+ *
473
+ * A polyline is a sequence of points that does not form a closed shape. Even if the
474
+ * polyline is closed, the only points that are part of the region are those that
475
+ * intersect (even minimally) a one-pixel line drawn along the polyline.
476
+ * The points are provided as pairs of X,Y coordinates, in the order X<sub>1</sub>,
477
+ * Y<sub>1</sub>, X<sub>2</sub>, Y<sub>2</sub>, ..., X<sub>n</sub>, Y<sub>n</sub>.
478
+ *
479
+ * Possible usage (in C++):
480
+ * @code
481
+ * int num_polyline_points = heif_region_get_polyline_num_points(region);
482
+ * if (num_polyline_points > 0) {
483
+ * std::vector<int32_t> polyline(num_polyline_points * 2);
484
+ * heif_region_get_polyline_points(region, polyline.data());
485
+ * // do something with points ...
486
+ * }
487
+ * @endcode
488
+ *
489
+ * @param region the region to query, which must be of type #heif_region_type_polyline
490
+ * @param out_pts_array the array to return the points in, which must have twice as many entries as there are points
491
+ * in the polyline.
492
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
493
+ *
494
+ * \sa heif_region_get_polyline_points_transformed() for a version in pixels after all transformative properties have been applied.
495
+ */
496
+ LIBHEIF_API
497
+ heif_error heif_region_get_polyline_points(const heif_region* region,
498
+ int32_t* out_pts_array);
499
+
500
+ /**
501
+ * Get the transformed points in a polyline region.
502
+ *
503
+ * This returns the coordinates in pixels after all transformative properties have been applied.
504
+ *
505
+ * A polyline is a sequence of points that does not form a closed shape. Even if the
506
+ * polyline is closed, the only points that are part of the region are those that
507
+ * intersect (even minimally) a one-pixel line drawn along the polyline.
508
+ * The points are provided as pairs of X,Y coordinates, in the order X<sub>1</sub>,
509
+ * Y<sub>1</sub>, X<sub>2</sub>, Y<sub>2</sub>, ..., X<sub>n</sub>, Y<sub>n</sub>.
510
+ *
511
+ * @param region the region to query, which must be of type #heif_region_type_polyline
512
+ * @param image_id the identifier for the image to transform / scale the region to
513
+ * @param out_pts_array the array to return the points in, which must have twice as many entries as there are points
514
+ * in the polyline.
515
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
516
+ *
517
+ * \sa heif_region_get_polyline_points() for a version that returns the values in the reference coordinate space.
518
+ */
519
+ LIBHEIF_API
520
+ heif_error heif_region_get_polyline_points_transformed(const heif_region* region,
521
+ heif_item_id image_id,
522
+ double* out_pts_array);
523
+
524
+ /**
525
+ * Get a referenced item mask region.
526
+ *
527
+ * This returns the values in the reference coordinate space (from the parent region item).
528
+ * The mask location is represented by a top left corner position, and a size defined
529
+ * by a width and height. The value of each sample in that mask identifies whether the
530
+ * corresponding pixel is part of the region.
531
+ *
532
+ * The mask is provided as an image in another item. The image item containing the mask
533
+ * is one of:
534
+ *
535
+ * - a mask item (see ISO/IEC 23008-12:2022 Section 6.10.2), or a derived
536
+ * image from a mask item
537
+ *
538
+ * - an image item in monochrome format (4:0:0 chroma)
539
+ *
540
+ * - an image item in colour format with luma and chroma planes (e.g. 4:2:0)
541
+ *
542
+ * If the pixel value is equal to the minimum sample value (e.g. 0 for unsigned
543
+ * integer), the pixel is not part of the region. If the pixel value is equal
544
+ * to the maximum sample value (e.g. 255 for 8 bit unsigned integer), the pixel
545
+ * is part of the region. If the pixel value is between the minimum sample value
546
+ * and maximum sample value, the pixel value represents an (application defined)
547
+ * probability that the pixel is part of the region, where higher pixel values
548
+ * correspond to higher probability values.
549
+ *
550
+ * @param region the region to query, which must be of type #heif_region_type_referenced_mask.
551
+ * @param out_x the X coordinate for the top left corner, where 0 is the left-most column.
552
+ * @param out_y the Y coordinate for the top left corner, where 0 is the top-most row.
553
+ * @param out_width the width of the mask region
554
+ * @param out_height the height of the mask region
555
+ * @param out_mask_item_id the item identifier for the image that provides the mask.
556
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
557
+ */
558
+ LIBHEIF_API
559
+ heif_error heif_region_get_referenced_mask_ID(const heif_region* region,
560
+ int32_t* out_x, int32_t* out_y,
561
+ uint32_t* out_width, uint32_t* out_height,
562
+ heif_item_id* out_mask_item_id);
563
+
564
+ /**
565
+ * Get the length of the data in an inline mask region.
566
+ *
567
+ * @param region the region to query, which must be of type #heif_region_type_inline_mask.
568
+ * @return the number of bytes in the mask data, or 0 on error.
569
+ */
570
+ LIBHEIF_API
571
+ size_t heif_region_get_inline_mask_data_len(const heif_region* region);
572
+
573
+
574
+ /**
575
+ * Get data for an inline mask region.
576
+ *
577
+ * This returns the values in the reference coordinate space (from the parent region item).
578
+ * The mask location is represented by a top left corner position, and a size defined
579
+ * by a width and height.
580
+ *
581
+ * The mask is held as inline data on the region, one bit per pixel, most significant
582
+ * bit first pixel, no padding. If the bit value is `1`, the corresponding pixel is
583
+ * part of the region. If the bit value is `0`, the corresponding pixel is not part of the
584
+ * region.
585
+ *
586
+ * Possible usage (in C++):
587
+ * @code
588
+ * long unsigned int data_len = heif_region_get_inline_mask_data_len(region);
589
+ * int32_t x, y;
590
+ * uint32_t width, height;
591
+ * std::vector<uint8_t> mask_data(data_len);
592
+ * err = heif_region_get_inline_mask(region, &x, &y, &width, &height, mask_data.data());
593
+ * @endcode
594
+ *
595
+ * @param region the region to query, which must be of type #heif_region_type_inline_mask.
596
+ * @param out_x the X coordinate for the top left corner, where 0 is the left-most column.
597
+ * @param out_y the Y coordinate for the top left corner, where 0 is the top-most row.
598
+ * @param out_width the width of the mask region
599
+ * @param out_height the height of the mask region
600
+ * @param out_mask_data the location to return the mask data
601
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
602
+ */
603
+ LIBHEIF_API
604
+ heif_error heif_region_get_inline_mask_data(const heif_region* region,
605
+ int32_t* out_x, int32_t* out_y,
606
+ uint32_t* out_width, uint32_t* out_height,
607
+ uint8_t* out_mask_data);
608
+
609
+ /**
610
+ * Get a mask region image.
611
+ *
612
+ * This returns the values in the reference coordinate space (from the parent region item).
613
+ * The mask location is represented by a top left corner position, and a size defined
614
+ * by a width and height.
615
+ *
616
+ * This function works when the passed region is either a heif_region_type_referenced_mask or
617
+ * a heif_region_type_inline_mask.
618
+ * The returned image is a monochrome image where each pixel represents the (scaled) probability
619
+ * of the pixel being part of the mask.
620
+ *
621
+ * If the region type is an inline mask, which always holds a binary mask, this function
622
+ * converts the binary inline mask to an 8-bit monochrome image with the values '0' and '255'.
623
+ * The pixel value is set to `255` where the pixel is part of the region, and `0` where the
624
+ * pixel is not part of the region.
625
+ *
626
+ * @param region the region to query, which must be of type #heif_region_type_inline_mask.
627
+ * @param out_x the X coordinate for the top left corner, where 0 is the left-most column.
628
+ * @param out_y the Y coordinate for the top left corner, where 0 is the top-most row.
629
+ * @param out_width the width of the mask region
630
+ * @param out_height the height of the mask region
631
+ * @param out_mask_image the returned mask image
632
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
633
+ *
634
+ * \note the caller is responsible for releasing the mask image
635
+ */
636
+ LIBHEIF_API
637
+ heif_error heif_region_get_mask_image(const heif_region* region,
638
+ int32_t* out_x, int32_t* out_y,
639
+ uint32_t* out_width, uint32_t* out_height,
640
+ heif_image** out_mask_image);
641
+
642
+ // --- adding region items
643
+
644
+ /**
645
+ * Add a region item to an image.
646
+ *
647
+ * The region item is a collection of regions (point, polyline, polygon, rectangle, ellipse or mask)
648
+ * along with a reference size (width and height) that forms the coordinate basis for the regions.
649
+ *
650
+ * The concept is to add the region item, then add one or more regions to the region item.
651
+ *
652
+ * @param image_handle the image to attach the region item to.
653
+ * @param reference_width the width of the reference size.
654
+ * @param reference_height the height of the reference size.
655
+ * @param out_region_item the resulting region item
656
+ * @return heif_error_ok on success, or an error indicating the problem on failure
657
+ */
658
+ LIBHEIF_API
659
+ heif_error heif_image_handle_add_region_item(heif_image_handle* image_handle,
660
+ uint32_t reference_width, uint32_t reference_height,
661
+ heif_region_item** out_region_item);
662
+
663
+ /**
664
+ * Add a point region to the region item.
665
+ *
666
+ * @param region_item the region item that holds this point region
667
+ * @param x the x value for the point location
668
+ * @param y the y value for the point location
669
+ * @param out_region pointer to pointer to the returned region (optional, see below)
670
+ * @return heif_error_ok on success, or an error indicating the problem on failure
671
+ *
672
+ * @note The `out_region` parameter is optional, and can be set to `NULL` if not needed.
673
+ */
674
+ LIBHEIF_API
675
+ heif_error heif_region_item_add_region_point(heif_region_item* region_item,
676
+ int32_t x, int32_t y,
677
+ heif_region** out_region);
678
+
679
+ /**
680
+ * Add a rectangle region to the region item.
681
+ *
682
+ * @param region_item the region item that holds this rectangle region
683
+ * @param x the x value for the top-left corner of this rectangle region
684
+ * @param y the y value for the top-left corner of this rectangle region
685
+ * @param width the width of this rectangle region
686
+ * @param height the height of this rectangle region
687
+ * @param out_region pointer to pointer to the returned region (optional, see below)
688
+ * @return heif_error_ok on success, or an error indicating the problem on failure
689
+ *
690
+ * @note The `out_region` parameter is optional, and can be set to `NULL` if not needed.
691
+ */
692
+ LIBHEIF_API
693
+ heif_error heif_region_item_add_region_rectangle(heif_region_item* region_item,
694
+ int32_t x, int32_t y,
695
+ uint32_t width, uint32_t height,
696
+ heif_region** out_region);
697
+
698
+ /**
699
+ * Add a ellipse region to the region item.
700
+ *
701
+ * @param region_item the region item that holds this ellipse region
702
+ * @param x the x value for the centre of this ellipse region
703
+ * @param y the y value for the centre of this ellipse region
704
+ * @param radius_x the radius of the ellipse in the X (horizontal) direction
705
+ * @param radius_y the radius of the ellipse in the Y (vertical) direction
706
+ * @param out_region pointer to pointer to the returned region (optional, see below)
707
+ * @return heif_error_ok on success, or an error indicating the problem on failure
708
+ *
709
+ * @note The `out_region` parameter is optional, and can be set to `NULL` if not needed.
710
+ */
711
+ LIBHEIF_API
712
+ heif_error heif_region_item_add_region_ellipse(heif_region_item* region_item,
713
+ int32_t x, int32_t y,
714
+ uint32_t radius_x, uint32_t radius_y,
715
+ heif_region** out_region);
716
+
717
+ /**
718
+ * Add a polygon region to the region item.
719
+ *
720
+ * A polygon is a sequence of points that form a closed shape. The first point does
721
+ * not need to be repeated as the last point.
722
+ * The points are provided as pairs of X,Y coordinates, in the order X<sub>1</sub>,
723
+ * Y<sub>1</sub>, X<sub>2</sub>, Y<sub>2</sub>, ..., X<sub>n</sub>, Y<sub>n</sub>.
724
+ *
725
+ * @param region_item the region item that holds this polygon region
726
+ * @param pts_array the array of points in X,Y order (see above)
727
+ * @param nPoints the number of points
728
+ * @param out_region pointer to pointer to the returned region (optional, see below)
729
+ * @return heif_error_ok on success, or an error indicating the problem on failure
730
+ *
731
+ * @note `nPoints` is the number of points, not the number of elements in the array
732
+ * @note The `out_region` parameter is optional, and can be set to `NULL` if not needed.
733
+ */
734
+ LIBHEIF_API
735
+ heif_error heif_region_item_add_region_polygon(heif_region_item* region_item,
736
+ const int32_t* pts_array, int nPoints,
737
+ heif_region** out_region);
738
+
739
+ /**
740
+ * Add a polyline region to the region item.
741
+ *
742
+ * A polyline is a sequence of points that does not form a closed shape. Even if the
743
+ * polyline is closed, the only points that are part of the region are those that
744
+ * intersect (even minimally) a one-pixel line drawn along the polyline.
745
+ * The points are provided as pairs of X,Y coordinates, in the order X<sub>1</sub>,
746
+ * Y<sub>1</sub>, X<sub>2</sub>, Y<sub>2</sub>, ..., X<sub>n</sub>, Y<sub>n</sub>.
747
+ *
748
+ * @param region_item the region item that holds this polyline region
749
+ * @param pts_array the array of points in X,Y order (see above)
750
+ * @param nPoints the number of points
751
+ * @param out_region pointer to pointer to the returned region (optional, see below)
752
+ * @return heif_error_ok on success, or an error indicating the problem on failure
753
+ *
754
+ * @note `nPoints` is the number of points, not the number of elements in the array
755
+ * @note The `out_region` parameter is optional, and can be set to `NULL` if not needed.
756
+ */
757
+ LIBHEIF_API
758
+ heif_error heif_region_item_add_region_polyline(heif_region_item* region_item,
759
+ const int32_t* pts_array, int nPoints,
760
+ heif_region** out_region);
761
+
762
+
763
+ /**
764
+ * Add a referenced mask region to the region item.
765
+ *
766
+ * The region geometry is described by the pixels in another image item,
767
+ * which has a item reference of type `mask` from the region item to the
768
+ * image item containing the mask.
769
+ *
770
+ * The image item containing the mask is one of:
771
+ *
772
+ * - a mask item (see ISO/IEC 23008-12:2022 Section 6.10.2), or a derived
773
+ * image from a mask item
774
+ *
775
+ * - an image item in monochrome format (4:0:0 chroma)
776
+ *
777
+ * - an image item in colour format with luma and chroma planes (e.g. 4:2:0)
778
+ *
779
+ * If the pixel value is equal to the minimum sample value (e.g. 0 for unsigned
780
+ * integer), the pixel is not part of the region. If the pixel value is equal
781
+ * to the maximum sample value (e.g. 255 for 8 bit unsigned integer), the pixel
782
+ * is part of the region. If the pixel value is between the minimum sample value
783
+ * and maximum sample value, the pixel value represents an (application defined)
784
+ * probability that the pixel is part of the region, where higher pixel values
785
+ * correspond to higher probability values.
786
+ *
787
+ * @param region_item the region item that holds this mask region
788
+ * @param x the x value for the top-left corner of this mask region
789
+ * @param y the y value for the top-left corner of this mask region
790
+ * @param width the width of this mask region
791
+ * @param height the height of this mask region
792
+ * @param mask_item_id the item identifier for the mask that is referenced
793
+ * @param out_region pointer to pointer to the returned region (optional, see below)
794
+ * @return heif_error_ok on success, or an error indicating the problem on failure
795
+ *
796
+ * @note The `out_region` parameter is optional, and can be set to `NULL` if not needed.
797
+ */
798
+ LIBHEIF_API
799
+ heif_error heif_region_item_add_region_referenced_mask(heif_region_item* region_item,
800
+ int32_t x, int32_t y,
801
+ uint32_t width, uint32_t height,
802
+ heif_item_id mask_item_id,
803
+ heif_region** out_region);
804
+
805
+
806
+ /**
807
+ * Add an inline mask region to the region item.
808
+ *
809
+ * The region geometry is described by a top left corner position, and a size defined
810
+ * by a width and height.
811
+ *
812
+ * The mask is held as inline data on the region, one bit per pixel, most significant
813
+ * bit first pixel, no padding. If the bit value is `1`, the corresponding pixel is
814
+ * part of the region. If the bit value is `0`, the corresponding pixel is not part of the
815
+ * region.
816
+ *
817
+ * @param region_item the region item that holds this mask region
818
+ * @param x the x value for the top-left corner of this mask region
819
+ * @param y the y value for the top-left corner of this mask region
820
+ * @param width the width of this mask region
821
+ * @param height the height of this mask region
822
+ * @param mask_data the location to return the mask data
823
+ * @param mask_data_len the length of the mask data, in bytes
824
+ * @param out_region pointer to pointer to the returned region (optional, see below)
825
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
826
+ */
827
+ LIBHEIF_API
828
+ heif_error heif_region_item_add_region_inline_mask_data(heif_region_item* region_item,
829
+ int32_t x, int32_t y,
830
+ uint32_t width, uint32_t height,
831
+ const uint8_t* mask_data,
832
+ size_t mask_data_len,
833
+ heif_region** out_region);
834
+
835
+ /**
836
+ * Add an inline mask region image to the region item.
837
+ *
838
+ * The region geometry is described by a top left corner position, and a size defined
839
+ * by a width and height.
840
+ *
841
+ * The mask data is held as inline data on the region, one bit per pixel. The provided
842
+ * image is converted to inline data, where any pixel with a value >= 0x80 becomes part of the
843
+ * mask region. If the image width is less that the specified width, it is expanded
844
+ * to match the width of the region (zero fill on the right). If the image height is
845
+ * less than the specified height, it is expanded to match the height of the region
846
+ * (zero fill on the bottom). If the image width or height is greater than the
847
+ * width or height (correspondingly) of the region, the image is cropped.
848
+ *
849
+ * @param region_item the region item that holds this mask region
850
+ * @param x the x value for the top-left corner of this mask region
851
+ * @param y the y value for the top-left corner of this mask region
852
+ * @param width the width of this mask region
853
+ * @param height the height of this mask region
854
+ * @param image the image to convert to an inline mask
855
+ * @param out_region pointer to pointer to the returned region (optional, see below)
856
+ * @return heif_error_ok on success, or an error value indicating the problem on failure
857
+ */
858
+ LIBHEIF_API
859
+ heif_error heif_region_item_add_region_inline_mask(heif_region_item* region_item,
860
+ int32_t x, int32_t y,
861
+ uint32_t width, uint32_t height,
862
+ heif_image* image,
863
+ heif_region** out_region);
864
+ #ifdef __cplusplus
865
+ }
866
+ #endif
867
+
868
+ #endif