base: add pixel_format.coloration

This commit is contained in:
Nigel Tao committed 2024-09-08 10:37:43 +10:00
1 parent 85af5a4bed
commit affff51fbf
4 files changed
+62 -29

No files matched your search

+26
View File
@@ -321,6 +321,20 @@ typedef uint32_t wuffs_base__pixel_alpha_transparency;
// --------
// wuffs_base__pixel_coloration is whether a pixel format's color model has no
// color (alpha only), gray color or rich (non-gray) color. Rich color includes
// RGB, BGR, YCC, YCCK, CMY and CMYK.
//
// Coloration does not capture the alpha aspect of the color model. It does not
// distinguish RGB from RGBA.
typedef uint32_t wuffs_base__pixel_coloration;
#define WUFFS_BASE__PIXEL_COLORATION__NONE 0
#define WUFFS_BASE__PIXEL_COLORATION__GRAY 1
#define WUFFS_BASE__PIXEL_COLORATION__RICH 3
// --------
// Deprecated: use WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX_INCL.
#define WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX 4
@@ -349,6 +363,7 @@ typedef struct wuffs_base__pixel_format__struct {
inline bool is_indexed() const;
inline bool is_interleaved() const;
inline bool is_planar() const;
inline uint32_t coloration() const;
inline uint32_t num_planes() const;
inline wuffs_base__pixel_alpha_transparency transparency() const;
#endif // __cplusplus
@@ -455,6 +470,12 @@ wuffs_base__pixel_format__is_planar(const wuffs_base__pixel_format* f) {
return ((f->repr >> 16) & 0x03) != 0;
}
static inline uint32_t //
wuffs_base__pixel_format__coloration(const wuffs_base__pixel_format* f) {
uint32_t n = (f->repr) >> 29;
return (n <= 1) ? n : 3;
}
static inline uint32_t //
wuffs_base__pixel_format__num_planes(const wuffs_base__pixel_format* f) {
return ((f->repr >> 16) & 0x03) + 1;
@@ -497,6 +518,11 @@ wuffs_base__pixel_format::is_planar() const {
return wuffs_base__pixel_format__is_planar(this);
}
inline uint32_t //
wuffs_base__pixel_format::coloration() const {
return wuffs_base__pixel_format__coloration(this);
}
inline uint32_t //
wuffs_base__pixel_format::num_planes() const {
return wuffs_base__pixel_format__num_planes(this);