1
0
Fork 0

Spectre/Graphics/PixelFormat: Rework

source/Graphics/Image/IcoFormat.cpp: use new PixelFormat.
source/Graphics/Image.cpp: update to confirm with new PixelFormat
Spectre/Graphics/PixelFormat: add PF_getNumChannels()
Spectre/Graphics/PixelFormat: Rework the enum with proper naming convention and documentation.
This commit is contained in:
Henrik Hautakoski 2020-11-03 14:20:36 +01:00
parent 82add50157
commit c731cda1a2
5 changed files with 73 additions and 16 deletions

View file

@ -1,18 +1,49 @@
#ifndef SPECTRE_GRAPHICS_PIXELFORMAT_H
#define SPECTRE_GRAPHICS_PIXELFORMAT_H
#include <cstdint>
namespace sp {
enum PixelFormat
{
PF_Unknown = 0,
PF_RGB = 1, // Standard RGB: 24 bits per pixel, 8 bits are used for red, green, blue.
PF_RGBA = 2, // Standard RGBA: 32 bits per pixel, 8 bits are used for red, green, blue, alpha.
PF_32BGR = 3, // 32 bits per pixel, 8 bits are used for blue, green, red. Last 8 bits are unused.
PF_32BGRA = 4, // 32 bits per pixel, 8 bits are used for blue, green, red, alpha.
PF_Alpha = 5, // 8 bit alpha channel.
PF_Alpha = 1, // 8 bit alpha channel.
// Byte-order formats.
// Pixels are always ordered with the first channel at the first byte, second channel at the second byte.
// ---------------------------
PF_RGB = 2, // Standard RGB: 24 bits per pixel, 8 bits are used for red, green, blue.
PF_RGBX = 3, // 32 bits per pixel, 8 bits are used for red, green, Last 8 bits are unused.
PF_RGBA = 4, // Standard RGBA: 32 bits per pixel, 8 bits are used for red, green, blue, alpha.
PF_BGR = 5, // 24 bits per pixel, 8 bits are used for blue, green, red.
PF_BGRX = 6, // 32 bits per pixel, 8 bits are used for blue, green, red. Last 8 bits are unused.
PF_BGRA = 7, // 32 bits per pixel, 8 bits are used for blue, green, red, alpha.
// Packed formats.
// ---------------------------
// 32-bit: Pixels are in ordered in 32-bit words. where the first channel is stored at the most significant byte (MSB).
// these formats are architecture dependant (litte/big-endian).
// (MSB) | byte 0 | byte 1 | byte 2 | byte 3 | (LSB)
PF_RGBX32 = 8, // | rrrr rrrr | gggg gggg | bbbb bbbb | xxxx xxxx |
PF_RGBA32 = 9, // | rrrr rrrr | gggg gggg | bbbb bbbb | aaaa aaaa |
PF_BGRX32 = 10, // | bbbb bbbb | gggg gggg | rrrr rrrr | xxxx xxxx |
PF_BGRA32 = 11, // | bbbb bbbb | gggg gggg | rrrr rrrr | aaaa aaaa |
// 24-bit (unsuppored for now)
//PF_RGB24 = 12, // | rrrr rrrr | gggg gggg | bbbb bbbb |
//PF_BGR24 = 13, // | bbbb bbbb | gggg gggg | rrrr rrrr |
// 16-bit (unsuppored for now)
//PF_RGB565 = 14, // | rrrr rggg | gggb bbbb |
//PF_RGBA5551 = 15 // | rrrr rggg | ggb bbbba |
//PF_RGBX5551 = 16 // | rrrr rggg | ggb bbbbx |
};
uint8_t PF_getNumChannels(enum PixelFormat format);
} // namespace
#endif /* SPECTRE_GRAPHICS_PIXELFORMAT_H */