X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fpixelformat.h;h=13bc03a8c059325d7272120f5a486b58e7e5d01e;hb=e1be82a4dfce8d90358c506f65be09da4dc9d5ec;hp=71a8bd4c3de6c98994e618d3a382be4b9dbc1791;hpb=160e9eea29bd10034733d59507fa1bcca36be401;p=libs%2Fgl.git diff --git a/source/core/pixelformat.h b/source/core/pixelformat.h index 71a8bd4c..13bc03a8 100644 --- a/source/core/pixelformat.h +++ b/source/core/pixelformat.h @@ -9,8 +9,9 @@ namespace Msp { namespace GL { /** -Identifies the components of a pixel, without type information. The values -are bitfields laid as follows: +Identifies the components of a pixel, without type information. + +The values are bitfields laid as follows: _grs dccc │││ │ └╴Number of components @@ -20,7 +21,7 @@ _grs dccc └───────╴Grayscale flag This information is presented for internal documentation purposes only; it is -inadvisable for programs to rely on it. +inadvisable for applications to rely on it. */ enum PixelComponents { @@ -37,8 +38,21 @@ enum PixelComponents }; /** -Identifies a pixel format, with components and type. The values are bitfields -laid as follows: +Describes a mapping from one set of components to another. +*/ +enum ComponentSwizzle +{ + NO_SWIZZLE, + R_TO_LUMINANCE, + RG_TO_LUMINANCE_ALPHA, + RGB_TO_BGR, + RGBA_TO_RGB +}; + +/** +Identifies a pixel format, with components and type. + +The values are bitfields laid as follows: tnfg ssss cccc cccc ││││ │ └╴Components (see PixelComponents) @@ -49,7 +63,7 @@ tnfg ssss cccc cccc └──────────────────╴sRGB flag This information is presented for internal documentation purposes only; it is -inadvisable for programs to rely on it. +inadvisable for applications to rely on it. */ enum PixelFormat { @@ -87,6 +101,10 @@ void operator>>(const LexicalConverter &, PixelFormat &); PixelComponents components_from_graphics(Graphics::PixelFormat); PixelFormat pixelformat_from_image(const Graphics::Image &, bool = false); +ComponentSwizzle get_required_swizzle(PixelComponents); +PixelComponents swizzle_components(PixelComponents, ComponentSwizzle); +PixelComponents unswizzle_components(PixelComponents, ComponentSwizzle); + PixelFormat make_pixelformat(PixelComponents, DataType, bool = false); inline PixelComponents get_components(PixelFormat f) { return static_cast(f&0xFF); } inline unsigned get_component_count(PixelComponents c) { return c&7; }