Sign in to follow this  
romainechester

Loading a png image

Recommended Posts

romainechester    122
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
shmoove    821
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
Blew    358
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this