×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    43

    Question Which takes less memory Image object or byte[]

    Hi guys,

    I need to cache 10+ images and I'm trying to figure out which technique takes LESS phone's memory; Image object created from byte[] data or raw byte[] data?


    Thanks and BR,
    Damjan

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

    Re: Which takes less memory Image object or byte[]

    That depends where you get the byte[] from. If it's the PNG data, it is likely to be much smaller than the Image object it will create.

    You might want to read Tiger69's guide to the memory usage of Image objects.

    Graham.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    43

    Re: Which takes less memory Image object or byte[]

    Graham thanks for your reply and link.

    Images come from my webservice - at the moment all incoming images are in jpg format, but I can modify my service to serve pngs only.

    Any additional info on that matter will be much appreciated.

    BR,
    Damjan

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

    Re: Which takes less memory Image object or byte[]

    JPEGs should be smaller again than PNGs. Well, you know the size of a byte[] for the JPEG... it's the size of the JPEG file.

    The article in the wiki (see my previous post) will guide you as to the memory requirements of an Image object.

    There isn't really anything else to tell. You know how big the byte[] is. And the wiki has told you how many bytes to expect an Image object to require.

    Graham.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    43

    Re: Which takes less memory Image object or byte[] (solved)

    I understand now - actually I didn't know that jpg equals byte[] size

    Thanks for you help,
    Damjan


    Quote Originally Posted by grahamhughes View Post
    JPEGs should be smaller again than PNGs. Well, you know the size of a byte[] for the JPEG... it's the size of the JPEG file.

    The article in the wiki (see my previous post) will guide you as to the memory requirements of an Image object.

    There isn't really anything else to tell. You know how big the byte[] is. And the wiki has told you how many bytes to expect an Image object to require.

    Graham.

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

    Re: Which takes less memory Image object or byte[] (solved)

    Quote Originally Posted by dmalis View Post
    I understand now - actually I didn't know that jpg equals byte[] size
    Well, I'm assuming that you're reading a JPEG file from your server, and that you're reading it into a byte[] that has one byte for every byte of the file you're downloading.

    Something like:

    Code:
    HttpConnection con = (HttpConnection) Connector.open("http://someserver/someimage.jpg");
    int length = (int) con.getLength();
    byte[] data = new byte[length];
    Here is some more information about memory management in Java.

    Graham.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    43

    Re: Which takes less memory Image object or byte[]

    Yes that's the way I'm dealing with it. Thanks for another reference.

    Damjan

Similar Threads

  1. how to save byte image to phone memory
    By intheworldofmyown in forum Mobile Java General
    Replies: 17
    Last Post: 2008-12-12, 04:29
  2. How to get informations about an image without creating the Image Object
    By cristi.mota in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2008-06-27, 08:47
  3. Page builder
    By giogiogio in forum Symbian
    Replies: 2
    Last Post: 2007-08-26, 18:08
  4. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29
  5. Get pixel data from an image object on Nokia phones?
    By inopia in forum Mobile Java General
    Replies: 1
    Last Post: 2002-05-15, 09:27

Posting Permissions

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