mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-29 03:33:48 +00:00
d1cbc6f783
Now png/qoi/jpg are supported, and some subset of tga because we need that to load zga files for savegame thumbnails
39 lines
868 B
C++
39 lines
868 B
C++
#include <assert.h>
|
|
|
|
#define STB_IMAGE_IMPLEMENTATION
|
|
#define STBI_NO_STDIO
|
|
#define STBI_ONLY_JPEG
|
|
#define STBI_ONLY_PNG
|
|
#define STBI_ONLY_TGA
|
|
#include "stb_image.h"
|
|
|
|
#include <miniz.h>
|
|
|
|
static unsigned char * miniz_stbi_compress(unsigned char *data, int data_len, int *out_len, int quality)
|
|
{
|
|
mz_ulong maxsz = mz_compressBound(data_len);
|
|
unsigned char *packed = (unsigned char*)malloc(maxsz);
|
|
if(packed)
|
|
{
|
|
int result = mz_compress2(packed, &maxsz, data, data_len, quality);
|
|
if(result)
|
|
{
|
|
free(packed);
|
|
return NULL;
|
|
}
|
|
}
|
|
*out_len = (int)maxsz;
|
|
return packed;
|
|
}
|
|
|
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
|
#define STBIW_ZLIB_COMPRESS miniz_stbi_compress
|
|
#include "stb_image_write.h"
|
|
|
|
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
|
#define STBIR_ASSERT(x) assert(x)
|
|
#include "stb_image_resize.h"
|
|
|
|
#define QOI_IMPLEMENTATION
|
|
#define QOI_NO_STDIO
|
|
#include "qoi.h"
|