Utility/PixelFormat: Add experimental IdentifyFormat method
Only supports RGBA8 for now Former-commit-id: 8661dc7cab767de5d66efebe5e7038807ba712f7
This commit is contained in:
parent
e5f5d7ed11
commit
718713dbdd
|
|
@ -8,6 +8,7 @@
|
|||
#define NAZARA_PIXELFORMAT_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Bitset.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
|
@ -20,6 +21,34 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
struct PixelFormatInfo
|
||||
{
|
||||
PixelFormatInfo() :
|
||||
bitsPerPixel(0)
|
||||
{
|
||||
}
|
||||
|
||||
PixelFormatInfo(UInt8 bpp, PixelFormatSubType subType) :
|
||||
bitsPerPixel(bpp),
|
||||
redType(subType),
|
||||
greenType(subType),
|
||||
blueType(subType),
|
||||
alphaType(subType)
|
||||
{
|
||||
}
|
||||
|
||||
// Warning: Bit Endian
|
||||
Bitset<> redMask;
|
||||
Bitset<> greenMask;
|
||||
Bitset<> blueMask;
|
||||
Bitset<> alphaMask;
|
||||
PixelFormatSubType redType;
|
||||
PixelFormatSubType greenType;
|
||||
PixelFormatSubType blueType;
|
||||
PixelFormatSubType alphaType;
|
||||
UInt8 bitsPerPixel;
|
||||
};
|
||||
|
||||
class PixelFormat
|
||||
{
|
||||
friend class Utility;
|
||||
|
|
@ -41,6 +70,8 @@ namespace Nz
|
|||
|
||||
static bool HasAlpha(PixelFormatType format);
|
||||
|
||||
static PixelFormatType IdentifyFormat(const PixelFormatInfo& info);
|
||||
|
||||
static bool IsCompressed(PixelFormatType format);
|
||||
static bool IsConversionSupported(PixelFormatType srcFormat, PixelFormatType dstFormat);
|
||||
static bool IsValid(PixelFormatType format);
|
||||
|
|
|
|||
|
|
@ -1268,6 +1268,22 @@ namespace Nz
|
|||
}
|
||||
}
|
||||
|
||||
PixelFormatType PixelFormat::IdentifyFormat(const PixelFormatInfo& info)
|
||||
{
|
||||
switch (info.bitsPerPixel)
|
||||
{
|
||||
case 32:
|
||||
if (info.redMask == Bitset<>(0xFF000000) &&
|
||||
info.greenMask == Bitset<>(0x00FF0000) &&
|
||||
info.blueMask == Bitset<>(0x0000FF00) &&
|
||||
info.alphaMask == Bitset<>(0x000000FF))
|
||||
return PixelFormatType_RGBA8;
|
||||
break;
|
||||
}
|
||||
|
||||
return PixelFormatType_Undefined;
|
||||
}
|
||||
|
||||
bool PixelFormat::Initialize()
|
||||
{
|
||||
// Réinitialisation
|
||||
|
|
|
|||
Loading…
Reference in New Issue