2022-06-21 13:26:23 +00:00
|
|
|
#ifndef ENGINE_GFX_IMAGE_LOADER_H
|
|
|
|
#define ENGINE_GFX_IMAGE_LOADER_H
|
2022-06-11 07:09:42 +00:00
|
|
|
|
2023-02-28 19:41:07 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
2022-06-11 07:09:42 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
enum EImageFormat
|
|
|
|
{
|
|
|
|
IMAGE_FORMAT_R = 0,
|
2023-11-20 18:42:02 +00:00
|
|
|
IMAGE_FORMAT_RA,
|
2022-06-11 07:09:42 +00:00
|
|
|
IMAGE_FORMAT_RGB,
|
|
|
|
IMAGE_FORMAT_RGBA,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<uint8_t> TImageByteBuffer;
|
|
|
|
struct SImageByteBuffer
|
|
|
|
{
|
2022-06-27 12:36:13 +00:00
|
|
|
SImageByteBuffer(std::vector<uint8_t> *pvBuff) :
|
|
|
|
m_LoadOffset(0), m_pvLoadedImageBytes(pvBuff), m_Err(0) {}
|
2022-06-11 07:09:42 +00:00
|
|
|
size_t m_LoadOffset;
|
2022-06-27 12:36:13 +00:00
|
|
|
std::vector<uint8_t> *m_pvLoadedImageBytes;
|
2022-06-11 07:09:42 +00:00
|
|
|
int m_Err;
|
|
|
|
};
|
|
|
|
|
2022-06-27 14:57:23 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PNGLITE_COLOR_TYPE = 1 << 0,
|
|
|
|
PNGLITE_BIT_DEPTH = 1 << 1,
|
|
|
|
PNGLITE_INTERLACE_TYPE = 1 << 2,
|
|
|
|
PNGLITE_COMPRESSION_TYPE = 1 << 3,
|
|
|
|
PNGLITE_FILTER_TYPE = 1 << 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool LoadPNG(SImageByteBuffer &ByteLoader, const char *pFileName, int &PngliteIncompatible, int &Width, int &Height, uint8_t *&pImageBuff, EImageFormat &ImageFormat);
|
2022-06-11 07:09:42 +00:00
|
|
|
bool SavePNG(EImageFormat ImageFormat, const uint8_t *pRawBuffer, SImageByteBuffer &WrittenBytes, int Width, int Height);
|
|
|
|
|
2022-06-21 13:26:23 +00:00
|
|
|
#endif // ENGINE_GFX_IMAGE_LOADER_H
|