![]() |
|
Allegro 4.9.4: PNG support not working |
Todd Cope
Member #998
November 2000
![]() |
Is there anything special I need to do in order to get PNG support with the iio add-on? I have built the iio add-on with PNG support by pointing cmake to my zlib and png libraries but when I try to load the image with al_iio_load("whatever.png") it fails. I replaced that with iio_load_png("whatever.png") and the image loads fine. |
Wagner Soares
Member #9,011
September 2007
![]() |
do you tried al_iio_init();?? EDIT |
Todd Cope
Member #998
November 2000
![]() |
al_iio_load() is returning NULL when the file actually exists. Somehow I think the PNG loader is not being registered by al_iio_init(). In the source file I notice that the PNG loader is only registered if ALLEGRO_CFG_IIO_HAVE_PNG is defined. Presumably that is supposed to be done automatically by the build system but maybe somehow it isn't. Edit: I defined ALLEGRO_CFG_IIO_HAVE_PNG myself and it still fails to work. |
Wagner Soares
Member #9,011
September 2007
![]() |
I had to run cmake 3 times for it to work. //Path to a file. ZLIB_INCLUDE_DIR:PATH=C:\VSC\include //Path to a library. ZLIB_LIBRARY:FILEPATH=C:\VSC\lib\zlib.lib
if cmake couldn't find zlib, something like NOTFOUND (can't remeber, sorry) will be written. |
Todd Cope
Member #998
November 2000
![]() |
All those things are correct in my "CMakeCache.txt" and it still behaves as I described above. |
StevenVI
Member #562
July 2000
![]() |
This is an interesting issue. I tested myself under Linux with the latest SVN, and al_iio_load loads a png file just fine. If I ever end up in Windows I can try to install the 4.9.4 release and see what happens. I did nothing special with cmake, but in Linux things tend to work automatically. At least in my experience. __________________________________________________ |
Milan Mimica
Member #3,877
September 2003
![]() |
Quote: In the source file I notice that the PNG loader is only registered if ALLEGRO_CFG_IIO_HAVE_PNG is defined. Presumably that is supposed to be done automatically by the build system but maybe somehow it isn't. Not even in include/allegro5/internal/aintern_iio_cfg.h?
-- |
Todd Cope
Member #998
November 2000
![]() |
Here is the contents of that file: /* #undef ALLEGRO_CFG_IIO_HAVE_PNG */
|
Milan Mimica
Member #3,877
September 2003
![]() |
I would try to rebuild from scratch, with an empty CMake cache.
-- |
Todd Cope
Member #998
November 2000
![]() |
Did that two or three times already. |
Trent Gamblin
Member #261
April 2000
![]() |
For it to work for me, I have to add c:/mingw/lib and c:/mingw/include to my PATH before running CMake. Then it finds everything (zlib, png, freetype, etc).
|
Todd Cope
Member #998
November 2000
![]() |
Just tried it and indeed it did find everything I had but the runtime issue still remains. Even though libpng and libz are linked into liba5_iio, somehow al_iio_load() is not aware of this. I can still use iio_load_png() directly but that is not exposed by the API therefore I shouldn't really be doing that. I may tinker with it myself this afternoon and see if I can find out what is going on. |
Trent Gamblin
Member #261
April 2000
![]() |
Are you sure you're calling al_iio_init()?
|
Todd Cope
Member #998
November 2000
![]() |
Yes. I am loading other images as well (PCX, TGA) and all those work fine. Edit: I have confirmed that the PNG handler is not being added during al_iio_init(). Edit 2: ALLEGRO_CFG_IIO_HAVE_PNG is not defined when "iio.c" is being compiled even though cmake shows that it has found PNG support. I'm not sure how cmake works but according to the "CMakeLists.txt" file ALLEGRO_CFG_IIO_HAVE_PNG is defined when PNG_FOUND is true. If that's the case then somehow that information must not be getting passed along to the compiler. Edit 3: I redid everything from scratch in a new folder and it worked. I guess I screwed something up in all my tinkering with the settings. |
Trent Gamblin
Member #261
April 2000
![]() |
Ah, ok... that's a good thing. It means I don't have to hunt around for obscure bugs. Thanks for all your testing!
|
Todd Cope
Member #998
November 2000
![]() |
Hmm, it is not working. For some reason when I was rebuilding my project, a new executable wasn't being created. I remedied that problem and now the original problem still stands. |
Trent Gamblin
Member #261
April 2000
![]() |
Could you apply the attached patch and try it?
|
Todd Cope
Member #998
November 2000
![]() |
The patch fixed it! |
Trent Gamblin
Member #261
April 2000
![]() |
Ok, thanks for testing. I'll apply it to svn.
|
Peter Wang
Member #23
April 2000
|
Todd, can you tell me which version of CMake and which C compiler you're using? The patch Trent posted is only a hack (which will be reverted), and I'd like to figure out why it wasn't working before.
|
Todd Cope
Member #998
November 2000
![]() |
I'm using "CMake 2.6-patch 1." My compiler is "gcc version 3.4.2 (mingw-special)." |
Peter Wang
Member #23
April 2000
|
I tried it in a virtual machine with Windows XP, and a completely fresh installation of mingw. CMake 2.6-patch 1, gcc 3.4.2. Works for me. I unpacked allegro-4.9.4 in c:\allegro, and built in a subdirectory called "Build". c:\allegro\Build\include\allegro5\internal\aintern_iio_cfg.h contains: #define ALLEGRO_CFG_IIO_HAVE_PNG
ex_bitmap loaded a PNG file okay. So, I don't know what to make of it. To help you debug it, this is how it's supposed to work: - CMake finds zlib and libpng I can only imagine that you have another file called aintern_iio_cfg.h somewhere, which is being picked up instead. Try entering some gibberish into aintern_iio_cfg.h which would cause the C compiler to abort, just to make sure it's looking at the right file.
|
|