#pragma once
#include <cstdint>
#include <cstring>
#include <whiteout/common_types.h>
#include <whiteout/textures/texture.h>
namespace whiteout::textures::bmp {
static constexpr u16 BMP_SIGNATURE = 0x4D42;
static constexpr u32 BI_RGB = 0;
static constexpr u32 BI_BITFIELDS = 3;
#pragma pack(push, 1)
struct BmpFileHeader {
u16 signature; u32 fileSize; u16 reserved1; u16 reserved2; u32 dataOffset; };
struct BmpInfoHeader {
u32 headerSize; i32 width; i32 height; u16 planes; u16 bitsPerPixel; u32 compression; u32 imageSize; i32 xPixelsPerMeter; i32 yPixelsPerMeter; u32 colorsUsed; u32 colorsImportant; };
#pragma pack(pop)
static_assert(sizeof(BmpFileHeader) == 14, "BmpFileHeader must be 14 bytes");
static_assert(sizeof(BmpInfoHeader) == 40, "BmpInfoHeader must be 40 bytes");
inline u32 bmp_row_stride(u32 width, u16 bitsPerPixel) {
return ((width * bitsPerPixel + 31) / 32) * 4;
}
}