Hi,

I have been struggling for a while with cx_Freeze to have my Windows
executables handle PNG images, and more generally non-BMP images. So far, I
have always got the following error when I tried to load one: "File is not
a Windows BMP file". It seemed that a dependency was not correctly loaded
and that it prevented Pygame from handling any non-Bitmap image (and
indeed, pygame.image.get_extended returned 0). But I think that I
eventually solved this problem. I know I could have avoided it using
py2exe, but I am a Python 3 user, so cx_Freeze is the only accurate tool
for me.

So here's my solution, copied from Stack Overflow Q&A where I've just
answered a question about it. Hope that it can help, it is really annoying
to be obliged to use BMP…

 *The problem* It seems that there is a conflict between two possible
dependencies. The file jpeg.dllis included from the JRE (on Windows,
something like C:\Program Files\Java\jre6\bin\), but it is the wrong one.
It should be included from the Pygame directory, located within your Python
installation, at C:\Python31\lib\site-packages\pygame\. Don't know why
cx_Freeze prefers the one from the JRE, though…

*How to fix it?* It is quite easy. Just copy the correct file (the one from
Pygame) to the directory in which you execute the cx_Freeze script. When
you will start it, the script will look in the current directory first, and
will find the correct jpeg.dll. Your executable should be able to import
PNG images now.

Does it work for you too?
Rastagong

Reply via email to