Loading .png using IMG_Load()

I tried to load a non-BMP file using SDL_image library using IMG_Load()
function which is supposed to work for .png image format. But to my
disappointment, it is unable to load the image, while it works fine with
.bmp extention.

Does anyone know the reason for this and can you suggest a remedy?–
Chiranjoy

“The task ahead of us is never as great as the power behind us”

I tried to load a non-BMP file using SDL_image library using IMG_Load()
function which is supposed to work for .png image format. But to my
disappointment, it is unable to load the image, while it works fine with
.bmp extention.

Does anyone know the reason for this and can you suggest a remedy?

If the .png file isn’t corrupt, it’s probably that SDL_image was built
without png support.

–ryan.

I thing the latter is more likely with my case i.e. SDL_image was built
without .png support. Is there a way to address this issue? Because the
other formats viz. .jpg, .gif, etc. are supported but the problem is only
with .png.–
Chiranjoy

“The task ahead of us is never as great as the power behind us”

To be clear, you need to define LOAD_PNG for your build settings. If you
are using Visual Studio you can find it in your Project
Properties/C++/Preprocessor dialog. You will see that LOAD_BMP is already
defined, so add the other formats you want to support.

Here are my Preprocessor defines from VS2003 (debug build):

_DEBUG
WIN32
_WINDOWS
LOAD_BMP
LOAD_GIF
LOAD_JPG
LOAD_JPG_DYNAMIC="jpeg.dll"
LOAD_LBM
LOAD_PCX
LOAD_PNG
LOAD_PNG_DYNAMIC="libpng13.dll"
LOAD_PNM
LOAD_TGA
LOAD_TIF
LOAD_TIF_DYNAMIC="libtiff.dll"
LOAD_XPM
LOAD_XV
PNG_USE_DLL
ZLIB_DLL

If you are running on another platform you will need to change the second
two from Windows based to your platform. Not sure about the _DYNAMIC
settings for non-Windows.

Hope that helps.

  • Ken Rogoway
    Homebrew Software> ----- Original Message -----

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Ryan C. Gordon
Sent: Wednesday, February 14, 2007 11:07 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] Loading .png using IMG_Load()

I tried to load a non-BMP file using SDL_image library using IMG_Load()
function which is supposed to work for .png image format. But to my
disappointment, it is unable to load the image, while it works fine with
.bmp extention.

Does anyone know the reason for this and can you suggest a remedy?

If the .png file isn’t corrupt, it’s probably that SDL_image was built
without png support.

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date: 2/14/2007
4:17 PM


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date: 2/14/2007
4:17 PM

I am using g++ from commandline on Linux. Any function capable of loading
all file formats (including .png). Plz suggest.

Moreover what should I do to make IMG_Load() work on g++.–
Chiranjoy

“The task ahead of us is never as great as the power behind us”

Look in the makefile. Grep for LOAD_BMP. Look at the format for that. Add
a similar command for LOAD_PNG.

  • Ken_____

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Chiranjoy Chowdhuri
Sent: Wednesday, February 14, 2007 11:56 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] Loading .png using IMG_Load()

I am using g++ from commandline on Linux. Any function capable of loading
all file formats (including .png). Plz suggest.

Moreover what should I do to make IMG_Load() work on g++.


Chiranjoy

“The task ahead of us is never as great as the power behind us”


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date: 2/14/2007
4:17 PM


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date: 2/14/2007
4:17 PM

The makefile seems to be in place. There is an entry for png for every bmp.
Thanks for the replies, but unfortunately my program is still unable to load
.png file.–
Chiranjoy

“The task ahead of us is never as great as the power behind us”

This first time I tried to load a PNG, I forgot to change the string inside
of the program. You might want to check if your string in the program an
the file have the same name. I had “image.bmp” in the program, but the file
was “image.png”. It took me forever to figure out.On 2/14/07, Chiranjoy Chowdhuri wrote:

The makefile seems to be in place. There is an entry for png for every
bmp. Thanks for the replies, but unfortunately my program is still unable to
load .png file.


Chiranjoy

“The task ahead of us is never as great as the power behind us”

Chiranjoy Chowdhuri wrote:

I am using g++ from commandline on Linux. Any function capable of loading
all file formats (including .png). Plz suggest.

Moreover what should I do to make IMG_Load() work on g++.

  1. Make sure you have libpng installed.
  2. Re-run configure script without png disabling flags (should be
    enabled by default).
  3. Verify that it can find png libraries
  4. Rebuild it with make.

After doing something similar with few other packages too, you should be
more familiar with building things under GNU system.

– Kuisma

I installed the rpm from http://libsdl.org/projects/SDL_image all over again
and ran the demo code to check the support for different file formats…

Here is the output:

BMP is supported
GIF is supported
JPG is supported
LBM is supported
PCX is supported
IMG_Load: Unsupported image format
PNG is not supported, or the image data is corrupted
PNM is supported
TGA is supported
IMG_Load: Unsupported image format
TIF is not supported, or the image data is corrupted
XCF is supported
XPM is supported

There seems to be a problem with .png and .tif image format somehow. The
reason I am so concerned about .png especially is because since I am a
newbie, the tutorial I am following has all the image examples in .png
format. Can you suggest an alternative way?–
Chiranjoy

“The task ahead of us is never as great as the power behind us”

Hi Chiranjoy,

Link against libpng12.dll , if you want to load any png file. It works for me in windows.
I have not tried in Linux.

Regards,
Akbar> ----- Original Message -----

From: chiranjoys@gmail.com (Chiranjoy Chowdhuri)
To: A list for developers using the SDL library. (includes SDL-announce)
Sent: Thursday, February 15, 2007 7:46:03 PM
Subject: Re: [SDL] Loading .png using IMG_Load()

I installed the rpm from http://libsdl.org/projects/SDL_image all over again and ran the demo code to check the support for different file formats…

Here is the output:

BMP is supported
GIF is supported
JPG is supported
LBM is supported
PCX is supported
IMG_Load: Unsupported image format
PNG is not supported, or the image data is corrupted
PNM is supported
TGA is supported
IMG_Load: Unsupported image format
TIF is not supported, or the image data is corrupted
XCF is supported
XPM is supported

There seems to be a problem with .png and .tif image format somehow. The reason I am so concerned about .png especially is because since I am a newbie, the tutorial I am following has all the image examples in .png format. Can you suggest an alternative way?


Chiranjoy

“The task ahead of us is never as great as the power behind us”


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Need a quick answer? Get one in minutes from people who know.
Ask your question on www.Answers.yahoo.com