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-e03cc46cb475master
parent
9ecd5ddb45
commit
3357e7bb60
|
@ -27,8 +27,14 @@ namespace video
|
|||
// PNG function for error handling
|
||||
static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg)
|
||||
{
|
||||
os::Printer::log("PNG FATAL ERROR", msg, ELL_ERROR);
|
||||
longjmp(png_ptr->jmpbuf, 1);
|
||||
os::Printer::log("PNG fatal error", msg, ELL_ERROR);
|
||||
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
|
||||
|
@ -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;
|
||||
|
||||
// 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);
|
||||
// }
|
||||
|
||||
|
@ -107,7 +113,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const
|
|||
|
||||
// Allocate the png read struct
|
||||
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)
|
||||
{
|
||||
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
|
|||
if (BitDepth < 8)
|
||||
{
|
||||
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);
|
||||
#else
|
||||
png_set_gray_1_2_4_to_8(png_ptr);
|
||||
#endif
|
||||
else
|
||||
png_set_packing(png_ptr);
|
||||
}
|
||||
|
|
|
@ -281,7 +281,7 @@ IImage* CImageLoaderLMP::loadImage(irr::io::IReadFile* file) const
|
|||
|
||||
// maybe palette file
|
||||
u32 rawtexsize = header.width * header.height;
|
||||
if ( rawtexsize + sizeof ( header ) != file->getSize() )
|
||||
if ( rawtexsize + sizeof ( header ) != (u32)file->getSize() )
|
||||
return 0;
|
||||
|
||||
u8 *rawtex = new u8 [ rawtexsize ];
|
||||
|
|
Loading…
Reference in New Issue