Changeset View
Changeset View
Standalone View
Standalone View
source/lib/tex/tex_png.cpp
Show First 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | static void user_warning_fn(png_structp UNUSED(png_ptr), png_const_charp warning_msg) | ||||
debug_printf("libpng warning: %s\n", warning_msg); | debug_printf("libpng warning: %s\n", warning_msg); | ||||
} | } | ||||
TIMER_ADD_CLIENT(tc_png_decode); | TIMER_ADD_CLIENT(tc_png_decode); | ||||
// limitation: palette images aren't supported | // limitation: palette images aren't supported | ||||
Status TexCodecPng::decode(u8* RESTRICT data, size_t size, Tex* RESTRICT t) const | Status TexCodecPng::decode(u8* RESTRICT data, size_t size, Tex* RESTRICT t) const | ||||
{ | { | ||||
TIMER_ACCRUE(tc_png_decode); | TIMER_ACCRUE(tc_png_decode); | ||||
png_infop info_ptr = 0; | png_infop info_ptr = 0; | ||||
// allocate PNG structures; use default stderr and longjmp error handler, use custom | // allocate PNG structures; use default stderr and longjmp error handler, use custom | ||||
// warning handler to filter out useless messages | // warning handler to filter out useless messages | ||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, user_warning_fn); | png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, user_warning_fn); | ||||
if(!png_ptr) | if(!png_ptr) | ||||
return ERR::FAIL; | return ERR::FAIL; | ||||
Show All 16 Lines | TIMER_ACCRUE(tc_png_decode); | ||||
png_destroy_read_struct(&png_ptr, &info_ptr, 0); | png_destroy_read_struct(&png_ptr, &info_ptr, 0); | ||||
return ret; | return ret; | ||||
} | } | ||||
// limitation: palette images aren't supported | // limitation: palette images aren't supported | ||||
Status TexCodecPng::encode(Tex* RESTRICT t, DynArray* RESTRICT da) const | Status TexCodecPng::encode(Tex* RESTRICT t, DynArray* RESTRICT da, int UNUSED(quality)) const | ||||
{ | { | ||||
png_infop info_ptr = 0; | png_infop info_ptr = 0; | ||||
// allocate PNG structures; use default stderr and longjmp error handlers | // allocate PNG structures; use default stderr and longjmp error handlers | ||||
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); | png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); | ||||
if(!png_ptr) | if(!png_ptr) | ||||
WARN_RETURN(ERR::FAIL); | WARN_RETURN(ERR::FAIL); | ||||
info_ptr = png_create_info_struct(png_ptr); | info_ptr = png_create_info_struct(png_ptr); | ||||
Show All 19 Lines |
Wildfire Games · Phabricator