Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (515)
Games in Android Showcase (122)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Images in MIDP 1.0  (Read 1899 times)
0 Members and 1 Guest are viewing this topic.
Offline gingerfox

Senior Newbie




Dissertation Woes...


« Posted 2005-03-30 11:14:03 »

Hi guys, im new to the forum and could really do with some help!
I'm writing a crossword game in MIDP 1.0 for my final year project and im having problems with my images.
The basic game is finished, it 'builds' fine in the emulator and works fine through the 'run' button.
However... when i build the package, the game does not work when i double click on the jad and i get the runtime error 'images not found'
I dont understand this, the images are all held in the pngs are all held in the 'res' folder, but somehow are not linked to?
i load all my images vis the 'Image.createImage("/example.png") command.
I'm really confused, ive tried moving the images around the various folders but it makes no difference, any help would be greatly appreciated.
Cheers guys

Rich  Smiley
Offline gingerfox

Senior Newbie




Dissertation Woes...


« Reply #1 - Posted 2005-03-30 14:59:40 »

Hey,

Solved my own problem, very stupid mistake!!!

For future reference for those with similar problem,

("/example.PNG")  NOT ("/example.png") its case sensitive!

Still now i have a nullPointerException, ho hum...

Rich

Roll Eyes
Offline ribot

Junior Duke




Ribot - mobile UI specialist


« Reply #2 - Posted 2005-03-30 15:13:04 »

Glad you sorted your initial problem, do you have any screen shots of your application so far?

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gingerfox

Senior Newbie




Dissertation Woes...


« Reply #3 - Posted 2005-03-30 17:49:51 »

Hey Ribbot,

Cant send u any screenshots as of yet because the problem has resurfaced! maybe u can help?

I'm pretty sure that the case sensitivity is the problem so i changed all my src files so that the extensions were uppercase (ie. PNG not png) as this is how the images are saved in the res folder.

However, despite the changes in the source files, the jar still lists the images with lowercase extensions, hence leading to 'images not found' errors?

I'm puzzled, why are the changes in the src code not filtering through to the jar?

any thoughts much appreciated???

Cheers

Rich  Huh
Offline wooD

Senior Newbie




J2ME Developer


« Reply #4 - Posted 2005-03-30 20:59:44 »

You had it in the earlier code sample, but make sure you have a / in front of your file names. That one bit me once.

("/example.png")

You can also dump the contents of your jar to make sure it does have the file in it. You never know.

jar -tvf yourfile.jar

Wood

Offline ameano

Senior Newbie




abstract void


« Reply #5 - Posted 2005-03-31 05:31:00 »

Maybe you need to recompile your class file or any other class files that use it... i know it sounds silly but depending on the development environment this may have an effect Huh

Ameano
rules are there to be broken... same goes for the rules of programming classes in j2me
Offline gingerfox

Senior Newbie




Dissertation Woes...


« Reply #6 - Posted 2005-04-01 10:41:31 »

Right,

Much appreciative of the help so far and have had a mini break through, by changing the error messages on the different image creations i've narrowed it down to the following piece of code.

Its a constructor that creates a list of numbered options and appends the same png as an icon to each element via a for loop:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
public CrosswordList(){

      super("Clue Number:", List.IMPLICIT);

      for(int i=0; i<board.numberOfClues; i++){

            // initialise list and append image icons

            try{

                  append(clueList[i], Image.createImage ("/clueImage.png"));
           
            } // end of try

            catch (java.io.IOException x) {
         
                  throw new RuntimeException ("Images not found");

             } // end of catch


      } // end of for loop

      // add commands to list

      addCommand(showClue);
      addCommand(backList);
      setCommandListener(this);

} // end of overidden constructor


Ive included the whole constructor for completeness but its this bit that causes the problem because commenting it out removes the error:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
for(int i=0; i<board.numberOfClues; i++){

            // initialise list and append image icons

            try{

                  append(clueList[i], Image.createImage ("/clueImage.png"));
           
            } // end of try

            catch (java.io.IOException x) {
         
                  throw new RuntimeException ("Images not found");

             } // end of catch


      } // end of for loop


Thanks for the help guys

Rich
Offline shmoove

Junior Duke




Doh!


« Reply #7 - Posted 2005-04-01 12:15:59 »

Open up the jar (with any zip utility) and check that the file is there, and that it's in the root directory (since that's how you've coded it).

On a separate note, you are creating a new image for every item in the list. That's very wasteful. I suggest you change it to:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
 Image clueImage;
 try {
  clueImage = Image.createImage ("/clueImage.png");
 }
 catch (Exception e) {
  // instead of throwing an exception here
  // you should be displaying the data from this exception
  // to help you with the debugging, so I would create an
  // Alert or something like that instead of throwing
  // a RuntimeException
 }
 for(int i=0; i<board.numberOfClues; i++){
  append(clueList[i], clueImage);    
 } // end of for loop
 


shmooove
Offline gingerfox

Senior Newbie




Dissertation Woes...


« Reply #8 - Posted 2005-04-02 13:13:11 »

Cheers for the advice shmooove,

When i looked back over the code i realised how wasteful it was so moved the image creation outside and for some reason that fixed the error!

Not complaining though!

Should be ready for porting OTA soon, will post the URL when ready.

Thanks again for everyones' input.

Rich

Grin
Offline shmoove

Junior Duke




Doh!


« Reply #9 - Posted 2005-04-02 14:26:42 »

Quote
so moved the image creation outside and for some reason that fixed the error!


Smells like "out of memory" from here.

shmoove
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (30 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (39 views)
2014-10-26 19:37:11

Luminem (21 views)
2014-10-26 10:17:50

Luminem (25 views)
2014-10-26 10:14:04

theagentd (31 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (57 views)
2014-10-16 15:22:06

Norakomi (46 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!