PNG FATAL ERROR: Invalid image width

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
AzP
Posts: 16
Joined: Fri Jun 09, 2006 8:47 pm
Location: Stockholm, Sweden

Post by AzP »

Does Irrlicht still use it's own libpng on Linux (saw a comment in the changelog for 1.5 that it doesn't on Mac OS X)? I'm still dying to see my problem being fixed, either from the package maintainer in Gentoo, or in Irrlicht. But somehow nobody else seems to have the same problem I do.

It's more than one year later now, and I still see the same problem on my computer (both Gentoo (desktop) and Ubuntu (laptop).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, the OSX version had yet another libpng version. That one was removed. I guess no one fixes it because no one sees it. It's simply non reproducable on any of my Linux machines.
tgl
Posts: 1
Joined: Fri Jan 09, 2009 11:09 pm

Post by tgl »

It's an irrlicht bug.

Code: Select all

--- irrlicht-1.5/source/Irrlicht/CImageLoaderPNG.cpp~	2008-12-14 07:15:56.000000000 -0500
+++ irrlicht-1.5/source/Irrlicht/CImageLoaderPNG.cpp	2009-01-09 16:56:30.000000000 -0500
@@ -184,9 +184,14 @@
 
 	// Update the changes
 	png_read_update_info(png_ptr, info_ptr);
-	png_get_IHDR(png_ptr, info_ptr,
-		(png_uint_32*)&Width, (png_uint_32*)&Height,
-		&BitDepth, &ColorType, NULL, NULL, NULL);
+	{
+		png_uint_32 w,h;
+		png_get_IHDR(png_ptr, info_ptr,
+			     &w, &h,
+			     &BitDepth, &ColorType, NULL, NULL, NULL);
+		Width=w;
+		Height=h;
+	}
 
 	// Convert RGBA to BGRA
 	if (ColorType==PNG_COLOR_TYPE_RGB_ALPHA)
@@ -199,9 +204,14 @@
 	}
 
 	// Update the changes
-	png_get_IHDR(png_ptr, info_ptr,
-		(png_uint_32*)&Width, (png_uint_32*)&Height,
-		&BitDepth, &ColorType, NULL, NULL, NULL);
+	{
+		png_uint_32 w,h;
+		png_get_IHDR(png_ptr, info_ptr,
+			     &w, &h,
+			     &BitDepth, &ColorType, NULL, NULL, NULL);
+		Width=w;
+		Height=h;
+	}
 
 	// Create the image structure to be filled by png data
 	if (ColorType==PNG_COLOR_TYPE_RGB_ALPHA)
Curiously, there are three calls to png_get_IHDR in that file, of which
one does it correctly and these two don't.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, that would explain why the type change in the Irrlicht version of libpng fixes the issue on 64bit machines, while default versions do not work. I will apply this patch on the 1.5 branch now.
Post Reply