Add Image::has_alpha().
authorCarl Hetherington <cth@carlh.net>
Sat, 12 Apr 2025 09:31:56 +0000 (11:31 +0200)
committerCarl Hetherington <cth@carlh.net>
Sat, 12 Apr 2025 09:31:56 +0000 (11:31 +0200)
src/lib/image.cc
src/lib/image.h

index 80ef92d061416432bb5311d44ec73362345366aa..1d06ef4181184855b49bb34ca19d8be3011adf4b 100644 (file)
@@ -1728,3 +1728,12 @@ Image::crop(Crop crop) const
        return out;
 }
 
+
+bool
+Image::has_alpha() const
+{
+       auto const d = av_pix_fmt_desc_get(_pixel_format);
+       DCPOMATIC_ASSERT(d);
+       return d->flags & AV_PIX_FMT_FLAG_ALPHA;
+}
+
index 548ebf7171d5fd7aef4c6ea18a1fa64242c87b15..9eedaece7c034304e2a7676a01fc455a9e935832 100644 (file)
@@ -99,6 +99,8 @@ public:
                return _pixel_format;
        }
 
+       bool has_alpha() const;
+
        size_t memory_used () const;
 
        static std::shared_ptr<const Image> ensure_alignment (std::shared_ptr<const Image> image, Alignment alignment);