mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-03-06 14:27:44 +00:00
Added RGBA4 format to BMP file writer
This commit is contained in:
parent
3df3610361
commit
e21ea93319
|
@ -113,7 +113,28 @@ namespace Util
|
||||||
return uint8_t((255.0f / 1.0f) * float((*reinterpret_cast<const uint16_t *>(pixel) >> 15) & 0x1));
|
return uint8_t((255.0f / 1.0f) * float((*reinterpret_cast<const uint16_t *>(pixel) >> 15) & 0x1));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RGBA4
|
||||||
|
{
|
||||||
|
static const unsigned bytes_per_pixel = 2;
|
||||||
|
static inline uint8_t GetRed(const uint8_t *pixel)
|
||||||
|
{
|
||||||
|
return uint8_t((255.0f / 15.0f) * float((*reinterpret_cast<const uint16_t *>(pixel) >> 12) & 0xf));
|
||||||
|
}
|
||||||
|
static inline uint8_t GetGreen(const uint8_t *pixel)
|
||||||
|
{
|
||||||
|
return uint8_t((255.0f / 15.0f) * float((*reinterpret_cast<const uint16_t *>(pixel) >> 8) & 0xf));
|
||||||
|
}
|
||||||
|
static inline uint8_t GetBlue(const uint8_t *pixel)
|
||||||
|
{
|
||||||
|
return uint8_t((255.0f / 15.0f) * float((*reinterpret_cast<const uint16_t *>(pixel) >> 4) & 0xf));
|
||||||
|
}
|
||||||
|
static inline uint8_t GetAlpha(const uint8_t *pixel)
|
||||||
|
{
|
||||||
|
return uint8_t((255.0f / 15.0f) * float((*reinterpret_cast<const uint16_t *>(pixel) >> 0) & 0xf));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <class SurfaceFormat>
|
template <class SurfaceFormat>
|
||||||
static bool WriteSurfaceToBMP(const std::string &file_name, const uint8_t *pixels, int32_t width, int32_t height, bool flip_vertical)
|
static bool WriteSurfaceToBMP(const std::string &file_name, const uint8_t *pixels, int32_t width, int32_t height, bool flip_vertical)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue