×

Discussion Board

Results 1 to 4 of 4

Hybrid View

  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    1

    Unhappy Issue with loading image

    I am trying to retrieve all images in the specific folder,For that I created a vector and move that images to that vector, the code I used is

    imageNameVector.removeAllElements();
    try {
    FileConnection fc = (FileConnection)Connector.open("file:///e:/Images", Connector.READ_WRITE);
    if(!fc.exists())
    {
    fc.mkdir();
    }
    Enumeration filelist = fc.list("*.jpg", true);
    String filename;
    while(filelist.hasMoreElements()) {
    filename = (String) filelist.nextElement();
    imageNameVector.addElement(filename);
    }
    fc.close();
    }
    catch (IOException ioe)
    {
    System.out.println("IOException: "+ioe.getMessage());
    }
    catch (SecurityException se) {
    System.out.println("SecurityException: "+se.getMessage());
    }

    System.out.checkError();



    return imageNameVector;
    }


    now I want to retrieve the elements from the vector and convert it to image,

    imageName = (String) imageNameVector.elementAt(1);
    try{
    image = Image.createImage(imageName);
    }catch(Exception e){
    Alert alert = new Alert("Sngjfkgnlkjf") ;
    alert.setString(""+imageName+e);
    display.setCurrent(alert);
    }

    It shows an exception Abc,jpg cannot be read, Somebody pls help me to sort it out....

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Issue with loading image

    Hello Geethu,

    First thing i suspect is the file name, make sure the file name you are giving exists , and i think you need the entire path not just image1.jpg !!

    Regards,

  3. #3
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: Issue with loading image

    You might need to use FileConnection to create the images, and as gaba88 suggested, you would need to use the whole path.

    Try something like this:

    Code:
    String imagesPath = System.getProperty("fileconn.dir.memorycard") + "Images/";
    FileConnection fc = (FileConnection)Connector.open(imagesPath, Connector.READ_WRITE);
    ...
    ...
    		  String imageName = (String) imageNameVector.elementAt(0);
    		  Image image;
    		  try{
    			  FileConnection fc = (FileConnection) Connector.open(imagesPath+imageName);
    			  image = Image.createImage(fc.openInputStream());
    ...
    ...			  
    		  }
    -CarlosDL

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,073

    Re: Issue with loading image

    image = Image.createImage(imageName);
    This can be used to load images only from within the app JAR i.e. application resources

    Use the file connection to load the image as bytearray and create image out of it.

    You might need to re-size the image on the fly as large size images will create out of memory issue on S40 devices.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

Similar Threads

  1. Image rotates if movie clip position changed before image loading
    By supriyaakg in forum [Archived] Flash Lite on Nokia Devices
    Replies: 2
    Last Post: 2010-12-30, 03:27
  2. S60 v5 Emulator loading issue
    By JRAM in forum Tools and SDK Feedback (Closed)
    Replies: 1
    Last Post: 2009-09-18, 22:44
  3. loading bmp'a from mbm issue
    By shadow-2005 in forum Symbian User Interface
    Replies: 4
    Last Post: 2009-02-24, 12:09
  4. Loading HTTPFilter issue
    By voda_ovi_sb in forum Symbian
    Replies: 3
    Last Post: 2008-06-09, 15:38
  5. Replies: 2
    Last Post: 2003-04-21, 01:30

Posting Permissions

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