Results 1 to 3 of 3
  1. #1
    Pmarcoen is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    Default Display image from filesystem

    I seem to have a problem displaying an image from the phone's filesystem.

    The following code works for images that are in the res folder but not if the path references to a file on the filesystem ..

    path = "file:///C:/Data/Images/200908/25082009004.jpg";
    try {
    image = Image.createImage(path);
    } catch (IOException e) {
    e.printStackTrace();
    }
    imageItem = new ImageItem(null,image,ImageItem.LAYOUT_CENTER,"Imag e not found");
    form.append(imageItem);

    Do I need to use an inputStream ?
    If so, how ?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default

    You need the (optional) JSR-75: the FileConnection API. Note that this API is available on only a few high-end devices.

    db

  3. #3
    Pmarcoen is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    Default

    I actually AM using the FileConnection API (ok apparently I can't post the link to the site where I got the code because I don't have enough posts .. I'm gonna try to do it anyway by stripping some stuff, add .html after : j2mesamples.blogspot.com/2009/02/file-connection-using-j2me-api-jsr-75)

    The thing is, if I'm in the else of the displayCurrentRoot function, that checkes whether the element of the file list is a folder or an item (jpg), I want it to display my image.

    Normally it would just display the item's name with the currentDir variable like so :

    append(currentDir,null);

    Now I tried :

    Image img = Image.createImage(currentDir);
    append(currentDir,img);

    which didn't work, so I tried the entire path :

    String path = currentRoot.getURL() + currentDir;
    Image img = Image.createImage(path);
    append(currentDir,img);

    Your help is appreciated !

Similar Threads

  1. how to read an image and display
    By santhosh_el in forum AWT / Swing
    Replies: 2
    Last Post: 04-04-2009, 12:43 PM
  2. can display image in JFrame?
    By xCLARAx in forum AWT / Swing
    Replies: 14
    Last Post: 04-03-2009, 07:02 PM
  3. How to display image ?
    By Birkoff in forum AWT / Swing
    Replies: 7
    Last Post: 06-09-2008, 07:58 AM
  4. How to display an image in JApplet
    By fred in forum Java Applets
    Replies: 1
    Last Post: 07-24-2007, 02:02 AM

Tags for this Thread

Posting Permissions

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