#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2021 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_PIXELS_PIXELFORMATS_PIXELFORMATQUERY_H #define NUCLEX_PIXELS_PIXELFORMATS_PIXELFORMATQUERY_H #include "Nuclex/Pixels/Config.h" #include "Nuclex/Pixels/PixelFormat.h" #include // for std::optional namespace Nuclex { namespace Pixels { namespace PixelFormats { // ------------------------------------------------------------------------------------------- // /// Provides informations about pixel formats /// /// /// These methods provide additional informations (on top of the inlined methods /// provided in the PixelFormat.h file, , /// and ) which /// you can use for checking and - if necessary - for runtime-conversion of /// unsupported pixel formats into a supported but variable pixel format. /// /// class NUCLEX_PIXELS_TYPE PixelFormatQuery { /// Checks whether the specified pixel format has a red channel /// Pixel format that will be checked /// True if the specified pixel format has a red channel public: NUCLEX_PIXELS_API static bool HasRedChannel(PixelFormat pixelFormat); /// Checks whether the specified pixel format has a green channel /// Pixel format that will be checked /// True if the specified pixel format has a green channel public: NUCLEX_PIXELS_API static bool HasGreenChannel(PixelFormat pixelFormat); /// Checks whether the specified pixel format has a blue channel /// Pixel format that will be checked /// True if the specified pixel format has a blue channel public: NUCLEX_PIXELS_API static bool HasBlueChannel(PixelFormat pixelFormat); /// Checks whether the specified pixel format has an alpha channel /// Pixel format that will be checked /// True if the specified pixel format has an alpha channel public: NUCLEX_PIXELS_API static bool HasAlphaChannel(PixelFormat pixelFormat); /// Reports whether the pixel format uses of signed integers or floats /// Pixel format that will be checked /// /// True if the pixel format is either a floating point format or an integer format /// that uses unsigned integers /// public: NUCLEX_PIXELS_API static bool IsSignedFormat(PixelFormat pixelFormat); /// Reports whether the pixel format uses floating point channels /// Pixel format that will be checked /// True if the pixel format stores channels in floating point format public: NUCLEX_PIXELS_API static bool IsFloatFormat(PixelFormat pixelFormat); /// /// Checks whether the pixel format has channels that differ in their number of bits /// /// Pixel format that will be checked /// True if the pixel format has channels with different widths /// /// This will return false for formats such as A16-R16-G16-B16 or R8-G8 and it /// will return true for formats such as A2-R10-G10-B10 or R5-G6-B5. /// public: NUCLEX_PIXELS_API static bool HasDifferentlySizedChannels(PixelFormat pixelFormat); /// /// Checks whether all channels in the pixel format start on a byte boundary /// /// Pixel format that will be checked /// True if all channels in the pixel format start in a byte boundary /// /// This will return true only if each color channel's width is a multiple of 8 /// (and each channel begins at a bit index that's a multiple of 8). /// public: NUCLEX_PIXELS_API static bool AreAllChannelsByteAligned(PixelFormat pixelFormat); /// Reports whether the pixel format uses the opposite endianness /// Pixel format that will be checked /// /// /// True if the pixel format stores data in the opposite endianness from /// the current platform. If different endianness can be covered by simply stating /// the positions of color channels differently, that is preferred to flipping. /// /// /// For example, the pixel format A8-R8-G8-B8 is 32 bits wide. On little endian /// platforms, it will report that the alpha channel is in bits 0-7. On big endian /// platforms, will still be false, but it will /// report that the alpha channel is in bits 24-31. /// /// /// Formats with a _Flipped16, _Flipped32 or higher postfix always need to be /// flipped (in steps as indicated by the postfix, i.e. in _Flipped16 flip every /// two bytes, but don't flip the whole channel). /// /// public: NUCLEX_PIXELS_API static bool RequiresEndianFlip(PixelFormat pixelFormat); /// Looks up the index of the lowest bit in the red channel /// Pixel format that will be checked /// The index of the lowest red bit in the pixel format public: NUCLEX_PIXELS_API static std::optional GetLowestRedBitIndex( PixelFormat pixelFormat ); /// Looks up the index of the lowest bit in the green channel /// Pixel format that will be checked /// The index of the lowest green bit in the pixel format public: NUCLEX_PIXELS_API static std::optional GetLowestGreenBitIndex( PixelFormat pixelFormat ); /// Looks up the index of the lowest bit in the blue channel /// Pixel format that will be checked /// The index of the lowest blue bit in the pixel format public: NUCLEX_PIXELS_API static std::optional GetLowestBlueBitIndex( PixelFormat pixelFormat ); /// Looks up the index of the lowest bit in the alpha channel /// Pixel format that will be checked /// The index of the lowest alpha bit in the pixel format public: NUCLEX_PIXELS_API static std::optional GetLowestAlphaBitIndex( PixelFormat pixelFormat ); /// Counts the number of bits used for the red channel /// Pixel format that will be checked /// The number of red bits used in the pixel format public: NUCLEX_PIXELS_API static std::optional CountRedBits( PixelFormat pixelFormat ); /// Counts the number of bits used for the green channel /// Pixel format that will be checked /// The number of green bits used in the pixel format public: NUCLEX_PIXELS_API static std::optional CountGreenBits( PixelFormat pixelFormat ); /// Counts the number of bits used for the blue channel /// Pixel format that will be checked /// The number of blue bits used in the pixel format public: NUCLEX_PIXELS_API static std::optional CountBlueBits( PixelFormat pixelFormat ); /// Counts the number of bits used for the alpha channel /// Pixel format that will be checked /// The number of alpha bits used in the pixel format public: NUCLEX_PIXELS_API static std::optional CountAlphaBits( PixelFormat pixelFormat ); /// Counts the number of bits of the pixel format's widest channel /// Pixel format that will be checked /// The number of bits used by the pixel format's widest channel public: NUCLEX_PIXELS_API static std::size_t CountWidestChannelBits( PixelFormat PixelFormat ); }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Pixels::PixelFormats #endif // NUCLEX_PIXELS_PIXELFORMATS_PIXELFORMATQUERY_H