TexConv/pixel_format.h

83 lines
1.4 KiB
C
Raw Normal View History

2019-11-28 01:44:50 +08:00
#pragma once
2019-11-26 17:27:48 +08:00
#include<hgl/type/DataType.h>
using namespace hgl;
enum class ColorFormat
{
NONE=0,
BGRA4,
RGB565,
A1RGB5,
2019-12-03 20:49:25 +08:00
R8,
RG8,
RGBA8,
A2BGR10,
R16,
2019-11-26 17:27:48 +08:00
R16F,
2019-12-03 20:49:25 +08:00
RG16,
2019-11-26 17:27:48 +08:00
RG16F,
2019-12-03 20:49:25 +08:00
RGBA16,
2019-11-26 17:27:48 +08:00
RGBA16F,
R32U,
R32I,
R32F,
RG32U,
RG32I,
RG32F,
RGB32U,
RGB32I,
RGB32F,
RGBA32U,
RGBA32I,
RGBA32F,
END
};//enum class ColorFormat
enum class ColorDataType
{
NONE=0,
UNORM,
SNORM,
2019-12-02 22:10:49 +08:00
USCALE,
SSCALE,
2019-12-03 20:49:25 +08:00
UINT,
SINT,
2019-11-26 17:27:48 +08:00
UFLOAT,
SFLOAT,
2019-12-03 20:49:25 +08:00
SRGB,
2019-11-26 17:27:48 +08:00
END
};//enum class ColorDataType
struct ColorDataFormat
{
char color; //颜色成份 R/G/B/A/D等
ColorDataType type; //UNORM/SNORM等
uint8 bits; //位数
};//
struct PixelFormat
{
2019-11-26 17:54:02 +08:00
ColorFormat format;
char name[32];
2019-11-26 17:27:48 +08:00
2019-12-02 22:10:49 +08:00
uint8 channels; //颜色通道数
2019-11-26 17:27:48 +08:00
char color[4];
uint8 bits[4];
ColorDataType type;
public:
2019-12-02 22:10:49 +08:00
const uint GetPixelBytes()const{return (bits[0]+bits[1]+bits[2]+bits[3])>>3;} ///<获取单个象素所需字节数
2019-11-26 17:27:48 +08:00
};//
2019-11-26 17:54:02 +08:00
const PixelFormat *GetPixelFormat(ColorFormat); ///<根据获取获取象素格式类型
const PixelFormat *GetPixelFormat(const os_char *name); ///<根据名称获取象素格式类型
2019-11-28 01:44:50 +08:00
void PrintFormatList();