×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jun 2013
    Posts
    8

    Image rendering issue on Nokia 311 asha s40

    I'm making an app on lwuit form. This is the function to get images from SD card. The problem is that images greater than size 200KB are not rendering and the application crashes. Small size images are properly shown. Is there some input buffer limit on this phone?

    this is my function:
    private Image openFile(String fileName) {
    FileConnection fc = null;
    InputStream is = null;
    try {
    fc = (FileConnection) Connector.open(currDirName + fileName);
    System.out.println(fileName);
    if (!fc.exists()) {
    throw new IOException("File does not exists");
    }

    int size = (int) fc.fileSize();
    is = fc.openInputStream();
    Image image = Image.createImage(is);
    is.close();
    fc.close();

    return image;

    } catch (Exception e) {
    //CustomDialogBox.showDialog("Error", e.getMessage(), "ok");
    }
    return null;
    }

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,694

    Re: Image rendering issue on Nokia 311 asha s40

    There is a heap limit. Image objects occupy memory from your own heap, which has a not too large maximal size. See under Memory functions on the specification pages. On Series 40 it is a couple megabytes at most. Like the Nokia Asha 311: https://developer.nokia.com/Devices/...ions/Asha_311/ (4 MB) or the Nokia Asha 501 : https://developer.nokia.com/Devices/...ions/Asha_501/ (3 MB), and these are the large numbers. Most other Series 40 and Asha devices have 2.

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

    Re: Image rendering issue on Nokia 311 asha s40

    As you are using 311, you have 4MB of heap which is not very small if you use it optimally for your LWUIT app.
    I would suggest to use memory monitor and use images resized to mobile phones screen (or the actual size you wish to display in the list as icons or something) to avoid such issues.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  4. #4
    Registered User
    Join Date
    May 2008
    Location
    Surat Thani
    Posts
    260

    Re: Image rendering issue on Nokia 311 asha s40

    If you don't really need a full resolution image, as a workaround you could try getting the thumbnail from the JPG file's Exif data. At least on Nokia 310, the thumbnail size for photos taken with the device's camera is 320x240, which is even enough for showing the image full screen.

    Not sure if there's a existing snippet somewhere for getting the thumbnail bytes from a JPG file, but it's pretty easy to do based on the specs. Then just use Image.createImage with the thumbnail byte array as argument.

  5. #5
    Registered User
    Join Date
    Jun 2013
    Posts
    8

    Re: Image rendering issue on Nokia 311 asha s40

    I have modified my funtion using byte. But i'm still confused how to get thumbnail size..
    here is my code: help?

    private Image openFile(String fileName) {
    FileConnection fc = null;
    InputStream is = null;
    try {
    fc = (FileConnection) Connector.open(currDirName + fileName);

    if (!fc.exists()) {
    throw new IOException("File does not exists");
    }

    int size = (int) fc.fileSize();
    is = fc.openInputStream();
    byte bytes[] = new byte[size];
    is.read(bytes, 0, size);
    Image image = Image.createImage(bytes, 0, size);

    bytes = null;
    is.close();
    fc.close();

    return image;

    } catch (Exception e) {
    //CustomDialogBox.showDialog("Error", e.getMessage(), "ok");
    }
    return null;
    }

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,694

    Re: Image rendering issue on Nokia 311 asha s40

    What you did originally was opening the file, and creating an image of it in the memory.
    What you do now is opening the file, reading it into the memory, and creating an image of it in the memory.
    Now reading these two statements, the second one uses (would use) even more memory than the original. And the original did not fit into the memory.
    What TongMuan suggested is checking if the image file is following EXIF format (https://en.wikipedia.org/wiki/Exchan...ge_file_format), and if it contains a thumbnail. http://exif.org/ has some specifications, and searching for java exif parser will probably find you some ideas. Like http://stackoverflow.com/questions/1...f-info-encoded has some practical explanation, and also links some libraries. Combining with thumbnail may be even better, I would check http://atif-razzaq.blogspot.no/2009/...jpeg-exif.html for example.

  7. #7
    Registered User
    Join Date
    Jun 2013
    Posts
    8

    Re: Image rendering issue on Nokia 311 asha s40

    How does FB app for nokia 311 opens up whole gallery in grid? can I get code that Fb uses? it looks pretty fast..

Similar Threads

  1. Nokia Asha 501 Emulator - jar size issue
    By Giorg189 in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2013-07-16, 18:13
  2. Simultaneous video rendering - issue SOS
    By arvind_v in forum Streaming and Video
    Replies: 0
    Last Post: 2006-01-04, 15:12

Posting Permissions

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