diff --git a/include/avif/avif_cxx.h b/include/avif/avif_cxx.h index 1b4e560189..f369978cba 100644 --- a/include/avif/avif_cxx.h +++ b/include/avif/avif_cxx.h @@ -18,17 +18,20 @@ namespace avif // Struct to call the destroy functions in a unique_ptr. struct UniquePtrDeleter { - void operator()(avifEncoder * encoder) const { avifEncoderDestroy(encoder); } void operator()(avifDecoder * decoder) const { avifDecoderDestroy(decoder); } - void operator()(avifImage * image) const { avifImageDestroy(image); } + void operator()(avifEncoder * encoder) const { avifEncoderDestroy(encoder); } void operator()(avifGainMap * gainMap) const { avifGainMapDestroy(gainMap); } + void operator()(avifImage * image) const { avifImageDestroy(image); } + void operator()(avifRGBImage * image) const { avifRGBImageFreePixels(image); } }; // Use these unique_ptr to ensure the structs are automatically destroyed. -using EncoderPtr = std::unique_ptr; using DecoderPtr = std::unique_ptr; -using ImagePtr = std::unique_ptr; +using EncoderPtr = std::unique_ptr; using GainMapPtr = std::unique_ptr; +using ImagePtr = std::unique_ptr; +// To use when RGBImage actually owns the pixels. RGBImage can also be used as a view, in which case it does not own the pixels. +using RGBImagePtr = std::unique_ptr; } // namespace avif