ddnet/src/engine/shared/image_loader.h
Jupeyy 65ad57a448 Change from pnglite to libpng for PNG reading
This is desirable mainly because libpng is maintained and pnglite is
not. pnglite was last updated in 2007 (15 years ago) and probably has a
lot of security vulnerabilities.

libpng is an actively maintained library also used by browsers like
Firefox or Chromium, so it's less likely to contain security
vulnerabilities, also it's more likely to be packaged by Linux
distributions.
2022-06-21 13:37:14 +02:00

29 lines
744 B
C++

#ifndef ENGINE_SHARED_IMAGE_LOADER_H
#define ENGINE_SHARED_IMAGE_LOADER_H
#include <stddef.h>
#include <stdint.h>
#include <vector>
enum EImageFormat
{
IMAGE_FORMAT_R = 0,
IMAGE_FORMAT_RGB,
IMAGE_FORMAT_RGBA,
};
typedef std::vector<uint8_t> TImageByteBuffer;
struct SImageByteBuffer
{
SImageByteBuffer(TImageByteBuffer *pBuff) :
m_LoadOffset(0), m_pLoadedImageBytes(pBuff), m_Err(0) {}
size_t m_LoadOffset;
TImageByteBuffer *m_pLoadedImageBytes;
int m_Err;
};
bool LoadPNG(SImageByteBuffer &ByteLoader, const char *pFileName, int &Width, int &Height, uint8_t *&pImageBuff, EImageFormat &ImageFormat);
bool SavePNG(EImageFormat ImageFormat, const uint8_t *pRawBuffer, SImageByteBuffer &WrittenBytes, int Width, int Height);
#endif