×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    13

    Problem when creating images of large sizes.

    Hi,

    I want to read the images saved in the device and display on canvas of my application.
    I am able to read the image stream using fileconnection api.
    I could suceffully create the connection, read the stream and also the file size.

    But when I try to create image using Image.createImage(InputStream is) or createImage(bytearray,offset,size)
    methods, I am facing exceptions. (out of memory,IOException,IlegalArgumentException).
    The problem is with the image sizes.

    Did any one face such problems?
    I would be happy if anyone has solutions for this problem..
    Waiting for the replies.

    Mamatha

  2. #2
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Problem when creating images of large sizes.

    Quote Originally Posted by mamatha_j2me View Post
    Hi,

    I want to read the images saved in the device and display on canvas of my application.
    I am able to read the image stream using fileconnection api.
    I could suceffully create the connection, read the stream and also the file size.

    But when I try to create image using Image.createImage(InputStream is) or createImage(bytearray,offset,size)
    methods, I am facing exceptions. (out of memory,IOException,IlegalArgumentException).
    The problem is with the image sizes.

    Did any one face such problems?
    I would be happy if anyone has solutions for this problem..
    Waiting for the replies.

    Mamatha
    Ur question is ur answer. The exception shows that heap size is not sufficient to load the image.. which device r u using. Please check ur code with some high end set. check for any object created in a loop. Please avoid that if is it so. If still u got the same error with high end sets then please post ur code here.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    13

    Re: Problem when creating images of large sizes.

    Hi,
    Thanks for the reply,
    I checked the app in Nokia6681 and Nokia N95 as well.
    Same problem exists.

    below is the code :

    public void readImage(String imgPath)
    {
    try
    {

    FileConnection fileConn =(FileConnection)Connector.open(imgPath);
    System.gc();
    InputStream fis = fileConn.openInputStream();
    long overallSize = fileConn.fileSize();
    System.out.println("overallSize:" + overallSize);
    System.gc();
    currentImage = Image.createImage(fis);
    fis.close();
    fileConn.close();
    System.gc();
    repaint();
    }
    catch (IOException e)
    {
    System.out.println("io exception : " + e);
    }
    catch (Exception e)
    {
    e.printStackTrace();

    }

    }

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Problem when creating images of large sizes.

    What do you mean by "big"? I'd guess you're running out of memory.

    Cheers,
    Graham.

  5. #5
    Registered User
    Join Date
    Nov 2008
    Posts
    13

    Re: Problem when creating images of large sizes.

    The problem arises with images of size 200KB and more.
    I faced problem with image of size 285 KB.
    Last edited by mamatha_j2me; 2009-04-03 at 11:42.

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Problem when creating images of large sizes.

    What is the size of the images, in pixels?

  7. #7
    Registered User
    Join Date
    Nov 2008
    Posts
    13

    Re: Problem when creating images of large sizes.

    Image size: 373KB
    Pixels : 1280x960

  8. #8
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Problem when creating images of large sizes.

    And... how many such images do you load at once? An image of 1280x960 on a reasonably new phone will require around 5Mb of memory.

    Also: what format(s) are the images?

    If you embed the image files in the application's JAR, and use Image.createImage(filename), do you have the same problem(s)?

    Cheers,
    Graham.

  9. #9
    Registered User
    Join Date
    Apr 2009
    Posts
    3

    Re: Problem when creating images of large sizes.

    I think there is a heap issue tht's why its throwing error. Try this with images having less size(less than 200).

Similar Threads

  1. Problem in drawing the converted .svg images....
    By pawan_G in forum Symbian Media (Closed)
    Replies: 39
    Last Post: 2008-12-20, 11:44
  2. Problem creating player on N81
    By lamiaaMB in forum Mobile Java Media (Graphics & Sounds)
    Replies: 6
    Last Post: 2008-06-24, 19:03
  3. Replies: 2
    Last Post: 2008-04-24, 12:26
  4. Problem while creating images .
    By sachinwarang in forum Mobile Java General
    Replies: 2
    Last Post: 2006-04-12, 18:42
  5. memory problem regarding creating jar files
    By gaziani007 in forum Mobile Java General
    Replies: 3
    Last Post: 2005-01-02, 08:50

Posting Permissions

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