Jump to content
  • Advertisement
Sign in to follow this  
romainechester

Loading a png image

This topic is 4613 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello to all! Seeing that there isn't a thread already made regarding my problem. Its rather simple for you guys really. I was wondering how to load a png image properly. What I'm doing is...
image = Image.createImage("[name of image].png");
Well.. that definately doesn't work. Can anyone help me on this? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
You probably just need to add a leading slash:

image = Image.createImage("/[name of image].png");

That being said, depending on your build process the images might end up in a different place than the root directory, so it's useful to open up the jar you create and check the exact location of the image and adjust the path in createImage() according to that.
One last thing, the filenames on phones are case-sensitive so you have to make sure the names you use are exactly the same (pic.png!=pic.PNG).

shmoove

Share this post


Link to post
Share on other sites
drat! Why didn't I think of that in the first place... So embarassed. Well... the images are in the same directory as the source files so I assumed that there would be no need for "/"

Share this post


Link to post
Share on other sites
Most people have problems with that (i did!). I think it's an API flaw. The programmers shouldn't have to type that leading slash...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!