Commit 3357e7bb authored by hybrid's avatar hybrid

Fix deprecation warnings in PNG handling. Also added a warning message handler...

Fix deprecation warnings in PNG handling. Also added a warning message handler to get png warnings through the Irrlicht logger. Fix signed/unsigne comparison in WAL loader.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3367 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 9ecd5ddb
...@@ -27,8 +27,14 @@ namespace video ...@@ -27,8 +27,14 @@ namespace video
// PNG function for error handling // PNG function for error handling
static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg) static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg)
{ {
os::Printer::log("PNG FATAL ERROR", msg, ELL_ERROR); os::Printer::log("PNG fatal error", msg, ELL_ERROR);
longjmp(png_ptr->jmpbuf, 1); longjmp(png_jmpbuf(png_ptr), 1);
}
// PNG function for warning handling
static void png_cpexcept_warn(png_structp png_ptr, png_const_charp msg)
{
os::Printer::log("PNG warning", msg, ELL_WARNING);
} }
// PNG function for file reading // PNG function for file reading
...@@ -37,7 +43,7 @@ void PNGAPI user_read_data_fcn(png_structp png_ptr, png_bytep data, png_size_t l ...@@ -37,7 +43,7 @@ void PNGAPI user_read_data_fcn(png_structp png_ptr, png_bytep data, png_size_t l
png_size_t check; png_size_t check;
// changed by zola { // changed by zola {
io::IReadFile* file=(io::IReadFile*)png_ptr->io_ptr; io::IReadFile* file=(io::IReadFile*)png_get_io_ptr(png_ptr);
check=(png_size_t) file->read((void*)data,(u32)length); check=(png_size_t) file->read((void*)data,(u32)length);
// } // }
...@@ -107,7 +113,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const ...@@ -107,7 +113,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const
// Allocate the png read struct // Allocate the png read struct
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
NULL, (png_error_ptr)png_cpexcept_error, NULL); NULL, (png_error_ptr)png_cpexcept_error, (png_error_ptr)png_cpexcept_warn);
if (!png_ptr) if (!png_ptr)
{ {
os::Printer::log("LOAD PNG: Internal PNG create read struct failure\n", file->getFileName(), ELL_ERROR); os::Printer::log("LOAD PNG: Internal PNG create read struct failure\n", file->getFileName(), ELL_ERROR);
...@@ -162,11 +168,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const ...@@ -162,11 +168,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const
if (BitDepth < 8) if (BitDepth < 8)
{ {
if (ColorType==PNG_COLOR_TYPE_GRAY || ColorType==PNG_COLOR_TYPE_GRAY_ALPHA) if (ColorType==PNG_COLOR_TYPE_GRAY || ColorType==PNG_COLOR_TYPE_GRAY_ALPHA)
#if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MINOR > 3)
png_set_expand_gray_1_2_4_to_8(png_ptr); png_set_expand_gray_1_2_4_to_8(png_ptr);
#else
png_set_gray_1_2_4_to_8(png_ptr);
#endif
else else
png_set_packing(png_ptr); png_set_packing(png_ptr);
} }
......
...@@ -281,7 +281,7 @@ IImage* CImageLoaderLMP::loadImage(irr::io::IReadFile* file) const ...@@ -281,7 +281,7 @@ IImage* CImageLoaderLMP::loadImage(irr::io::IReadFile* file) const
// maybe palette file // maybe palette file
u32 rawtexsize = header.width * header.height; u32 rawtexsize = header.width * header.height;
if ( rawtexsize + sizeof ( header ) != file->getSize() ) if ( rawtexsize + sizeof ( header ) != (u32)file->getSize() )
return 0; return 0;
u8 *rawtex = new u8 [ rawtexsize ]; u8 *rawtex = new u8 [ rawtexsize ];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment