×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Very urgent!!!!

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    19

    Question Very urgent!!!!

    Hello,

    I have a problem, I want to load an image in my programm.
    It works, if i set the file name directly by Image.createImage("/filename.png"). But I have 20 images and they should be loaded not all together, but by definite circumctances. (f.e. in a for-looping). So I tryed to replace the file name by a variable. and it doesn't work!!!!
    What is my mistake???

    public Displayable bildDisplay(){
    if(bildForm == null){
    bildForm = new Form("Bild");
    try{
    Image foto = Image.createImage(bild);
    bildForm.append(foto);
    } catch(IOException e){
    }
    }
    return bildForm;
    }

    bild is a String, works good, but not in this part :_(
    Thanks a lot for any help!

    Lena

  2. #2
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: Very urgent!!!!

    If you are trying in an emulator, try to print what is assigned to "bild" before createImage() . Are you getting any Exception ?

    Regards
    Gopal

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    19

    Re: Very urgent!!!!

    I'm trying it on mobile. But I proofed, the bild gets the rigth string- rigth file name. I get NullPointerException.
    could it be, that it's impossible to use a variable in createImage(String)?

    thanks

  4. #4
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: Very urgent!!!!

    I tried now and a variable in createImage() works...

    Regards
    Gopal
    Twitter : @balagopalks
    Linkedin : @balagopalks

  5. #5
    Regular Contributor
    Join Date
    Sep 2003
    Posts
    78

    Re: Very urgent!!!!

    Can you please show us at least one value assigned to the bild variable?

    Thanks

    Regards
    Emanuele Pecorari

  6. #6
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: Very urgent!!!!

    I just tried with this in my existing app
    image1 = Image.createImage(test1);

    Regards
    Gopal
    Twitter : @balagopalks
    Linkedin : @balagopalks

  7. #7
    Regular Contributor
    Join Date
    Sep 2003
    Posts
    78

    Re: Very urgent!!!!

    Sorry,
    The question was for Lena.

    I agree with Gopal because createImage works for me with variable.

    Lena, be sure (for sure you already know) in the value passed to the method you have the path starting with "/".

    Regards,
    Emanuele Pecorari

  8. #8
    Registered User
    Join Date
    Jan 2008
    Posts
    19

    Re: Very urgent!!!!

    I get the bild value from an inputStream, which reads a text file.

    I tried to write it in many forms, it didn't work.
    f.e.
    "/foto.PNG"
    /foto.PNG
    or only foto and then i parsed it to one String with ("/" + bild + ".PNG" )in the method .
    I have some images, something about 20. and I wanted to list the file names in a text file and call then first the file name and with file name -> the image file.
    is it wrong?

  9. #9
    Registered User
    Join Date
    Jan 2008
    Posts
    19

    Re: Very urgent!!!!

    try {
    ort.setText(ortung(location.latitude,
    location.longitude).getName());
    inform = ortung(location.latitude,
    location.longitude).getInfo();
    bild = ortung(location.latitude,
    location.longitude).getBild();
    } catch (Exception e) {

  10. #10
    Regular Contributor
    Join Date
    Sep 2003
    Posts
    78

    Re: Very urgent!!!!

    Quote Originally Posted by LEnS View Post
    I get the bild value from an inputStream, which reads a text file.

    I tried to write it in many forms, it didn't work.
    f.e.
    "/foto.PNG"
    /foto.PNG
    or only foto and then i parsed it to one String with ("/" + bild + ".PNG" )in the method .
    I have some images, something about 20. and I wanted to list the file names in a text file and call then first the file name and with file name -> the image file.
    is it wrong?
    Are the files with the big letters extension (.PNG) or they have small letters (like ".png")?

    Sorry for the stupid qiestion but your problem is really weird.

    Regards,
    Emanuele Pecorari

  11. #11
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: Very urgent!!!!

    Did you find out exactly at which line of code you are getting NullPointerException ?

    Regards
    Gopal

  12. #12
    Registered User
    Join Date
    Jan 2008
    Posts
    19

    Re: Very urgent!!!!

    the source file is written with big letter: PNG

    here the code again with exception line:
    public Displayable bildDisplay(){
    if(bildForm == null){
    bildForm.setCommandListener(this);
    back = new Command("Zurück", Command.BACK, 1);
    bildForm.addCommand(back);
    ende = new Command("Ende", Command.EXIT, 1);
    bildForm.addCommand(ende);
    bildForm = new Form("Bild");
    try{
    Image foto = Image.createImage(bild);
    bildForm.append(foto);
    } catch(IOException e){
    String er = bild;
    StringItem err = new StringItem(null, er, Item.BUTTON);
    bildForm.append(err);
    }

    }
    return bildForm;
    }

    I've changed it a little bit. so i get no error or Exception,
    I get the File name. bild

  13. #13
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: Very urgent!!!!

    Quote Originally Posted by LEnS View Post
    I've changed it a little bit. so i get no error or Exception,
    I get the File name. bild
    Does it mean that the issue is solved ? Or else please explain what is the issue currently.

    Regards
    Gopal
    Twitter : @balagopalks
    Linkedin : @balagopalks

  14. #14
    Registered User
    Join Date
    Jan 2008
    Posts
    19

    Re: Very urgent!!!!

    that has not solved my problem :-(

    the images will not be loaded:-(((((

  15. #15
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Very urgent!!!!

    well the nullpointer exception can mean two things :
    - or the variable hasnt been assigned a value
    - or the midlet cant find the local image...

    some tips :
    - first of all use the same name as the picture and watch out because it's case sensitive, so if one of ur pictures is called : TestImage.png use -> String myPic = "/TestImage.png"
    and then
    Image wantedImage = Image.createImage(myPic);

    owh, and place the images in the root of ur project !!!!

Similar Threads

  1. pls help its urgent!!!
    By saipavani123 in forum Mobile Java General
    Replies: 5
    Last Post: 2006-09-05, 00:55
  2. 6630 and Http -- Nokia PLEASE HELP ME -- URGENT URGENT!!!!
    By earamsey in forum Mobile Java General
    Replies: 1
    Last Post: 2005-12-02, 17:06
  3. URGENT: how to save Image to JPEG Format?
    By rj_cybersilver in forum Mobile Java General
    Replies: 0
    Last Post: 2005-05-31, 11:04
  4. Streaming on 7600? Urgent...
    By nano404 in forum Streaming and Video
    Replies: 4
    Last Post: 2004-03-12, 12:11
  5. Need help compiling - Urgent!!!
    By tianlye in forum Symbian
    Replies: 2
    Last Post: 2003-03-31, 09:25

Posting Permissions

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