mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-02-21 03:21:37 +00:00
Use zlib for compression of png screenshots
This commit is contained in:
parent
c86cb9a982
commit
b880e8625b
1 changed files with 20 additions and 0 deletions
|
@ -47,7 +47,27 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "sys/win32/win_local.h"
|
||||
#endif
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
unsigned char* compress_for_stbiw(unsigned char* data, int data_len, int* out_len, int quality)
|
||||
{
|
||||
uLongf bufSize = compressBound(data_len);
|
||||
// note that buf will be free'd by stb_image_write.h
|
||||
// with STBIW_FREE() (plain free() by default)
|
||||
unsigned char* buf = (unsigned char*)malloc(bufSize);
|
||||
if (buf == NULL) return NULL;
|
||||
if (compress2(buf, &bufSize, data, data_len, quality) != Z_OK)
|
||||
{
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
*out_len = bufSize;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#define STBIW_ZLIB_COMPRESS compress_for_stbiw
|
||||
#include "stb_image_write.h"
|
||||
|
||||
// functions that are not called every frame
|
||||
|
|
Loading…
Reference in a new issue