heif_image_add_channel(): Possible bug?
https://github.com/strukturag/libheif/blob/master/libheif/api/libheif/heif.cc#L1824
The ! check does not seem to be equivalent to:
if (image->image->add_channel(channel, width, height, datatype, bit_depth, nullptr) != Error::Ok) {
Changing it to the latter seemed to avoid the Cannot allocate memory for image plane message.
cc. @farindk
Right, thanks. That line was overlooked when I changed the return type from bool to Error.
I have corrected it in the patch above.
Note that there is currently not much use for heif_image_add_channel() because the other data-types can only be saved by the 'uncompressed' codec and that part is not implemented yet. Everybody currently uses heif_image_add_plane() instead.
@farindk @pcdion is filing a separate issue about this because we are trying to output non-visual gridded coverage of real values in uncompressed HEIF from our OGC API - Coverages / Tiles API (e.g. elevation model, but could be multiple fields like relative humidity, temperature...).