×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    39

    image failed to load

    Hello i'm trying to load a tiny starship in a starfield, but the problem is there is no problem loading in the java's wireless toolkit 2.0 emulator, but when using Nokia Developer's Suite's default 6310i MIDP SDK 1.1 it failed. I will show my portion of code below:

    ------------------------------------------------------------------------------------

    Galaxy (StarfieldMIDlet midlet)
    {
    this.midlet = midlet;
    screenWidth = getWidth();
    screenHeight = getHeight();
    numLayers = 1;
    for(int i = 0; i < MAXFORESTARS; i++)
    {
    foreStar[i] = new Star(this, random.nextInt() & screenWidth, Math.abs(random.nextInt() % screenHeight), i, 'f');
    }

    keypadEnabled = true;
    quitCommand = new Command("Outta Here!", Command.EXIT, 1);
    startCommand = new Command("Show it!", Command.SCREEN, 1);
    pauseCommand = new Command("Pause it!", Command.SCREEN, 1);
    resumeCommand = new Command("Resume!", Command.SCREEN, 1);
    addCommand(quitCommand);
    addCommand(startCommand);
    setCommandListener(this);
    starship = new Ship(createImage("/ship.png"), screenWidth/2, screenHeight/2);
    new Thread(starship).start();
    }


    //this is the problem part
    private Image createImage(String filename)
    {
    try
    {
    image = Image.createImage(filename);
    System.out.println("Created image!");
    }
    catch(IOException e)
    {
    System.out.println("Create image failed!");
    image = null;
    }
    return image;
    }

    ------------------------------------------------------------------------------------

    in the wireless toolkit status message "created image" will always show but in the nokia emulator "create image failed" will always show, but i never change the position of my image "ship.png" which is in the Starfield\res\ folder.
    Could somebody please help?? I worked on these for few days with no results, thanx a million!

    Jin Kai

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    It is my experience that different tools pack the files in the jar in different ways. For example, you're example works with the WTK but if you were using JBuilder then you would need to put the image in the "src" folder. Try putting the image in different folders around your project, or playing with the path you use in your code (maybe "/res/ship.png" or "res/ship.png" or just "ship.png").

    shmoove

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    39

    thanx guys

    thanx everybody that read and thanx shmoove for answering my question, however i figured out the problem. Somehow png files made using Microsoft Windows's Paint can't work in the Nokia handphones, i don't know why, perhaps something to do with formatting and stuff, any suggestions? I used ProMotion to create then voila it loads!

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    19

    paint works

    i use microsoft paint to create png and it works in nokia emulator.
    i use jbuiler8 + 3650 concept sdk.

    thank shmoove. i tried many wrong paths until i saw your post

  5. #5
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Kluang
    Posts
    143
    Not bad, Pro Motion rocks, eh?

    So what kind of bug is this?

    Cheers,
    YC

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×