mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-02-18 03:45:41 +00:00
dep/stb: Use zlib for png compression
This commit is contained in:
parent
f8fe3cffd6
commit
673f9927ad
|
@ -10,4 +10,4 @@ set(SRCS
|
||||||
add_library(stb ${SRCS})
|
add_library(stb ${SRCS})
|
||||||
target_include_directories(stb PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
target_include_directories(stb PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||||
target_include_directories(stb INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
target_include_directories(stb INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||||
target_link_libraries(stb Threads::Threads "${CMAKE_DL_LIBS}")
|
target_link_libraries(stb zlib Threads::Threads "${CMAKE_DL_LIBS}")
|
||||||
|
|
|
@ -1,2 +1,28 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "zlib.h"
|
||||||
|
|
||||||
|
// https://github.com/nothings/stb/issues/113
|
||||||
|
static unsigned char* compress_for_stbiw(unsigned char* data, int data_len, int* out_len, int quality)
|
||||||
|
{
|
||||||
|
const 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 = 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 STBIW_ZLIB_COMPRESS compress_for_stbiw
|
||||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
#include "stb_image_write.h"
|
#include "stb_image_write.h"
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)dep\zlib\include;$(ProjectDir)include;$(ProjectDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue