×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    6

    Best practices for images and resources files

    Dear all,
    I'm very new to J2ME programming and so have little understanding of minimising application size. I'm currently developing and an application that uses xml files to store paths to images that are to be displayed in a gallery. It also uses xml to store other static information. Are there more efficient ways of doing this, as I'm becoming aware that as I add to the xml files, and the image directory, the app is becoming (unsurprisingly) larger.

    As a matter of interest what is an acceptable size for a mobile phone application?

    Angus

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

    Re: Best practices for images and resources files

    "Acceptable size" is defined by a number of factors.

    1. Some devices impose fixed limits on the size of JAR you can install. Series 40s, for example, do; Series 60s do not. Limits vary from device to device. Some old black-and-white devices have limits as low as 30k. Early (MIDP-1.0) Series 40s have a 64k limit. High-end Series 40s usually have a 1Mb limit. You can check the device specifications for this information.

    2. Some distribution channels may impose limits. If you're planning to sell your app through an app store (such as Ovi), check for any limits.

    3. Think about how long it will take to download your app. Longer download times make it more likely to get a signal drop-out during the download. Think also about cost. If users will download on a 2G network, I'd recommend you keep your app below 300k (well below, if the network doesn't support EDGE). For 3G, up to about 1Mb is sensible.

    As some guidelines, a 300k JAR will download in around:

    * 1.5 minutes, on GPRS
    * 20 seconds on EDGE
    * 10 seconds on 3G

    How many images do you have, and in what format(s)? What size are they (in both pixels and bytes)?

    XML files have the benefit that they compress quite well when added to the JAR.

    Graham.

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    6

    Re: Best practices for images and resources files

    Dear Graham,
    thanks for the reply, it proved interesting reading. I've not yet finalized the number of images, but I think it will be 20 at the most. All the images are in png format, and sizes vary depending on their content but range from 94kb to 31kb. Currently they all have the same dimension - 240 x 320. My intention is to display them in a gallery for the user to scroll through. Would I be better off converting them into byte arrays to increase speed of the application and their rendering?

    Regards

    Angus

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: Best practices for images and resources files

    Hello,
    If you have 20 images and let us assume the average size of the per image as 50 KB then only images will be more than a MB.Now you have the XML files, these will again take the space.What you remains with are the Java files.

    I would recommend you to minimize the size of per image. you can compress the image using the tool called as pngout.exe,in order to reduce the size.

    using XML uses xml files to store paths to images that are to be displayed in a gallery
    For this you can simply use the String variable rather then using the files.

    It also uses xml to store other static information
    How many this kind of values are?
    if these are not many in number then simply you can save the same in jad attributes,and then you can fetch the same from the midlet properties using,
    midletObject.getAppPrpoerty("Key");

    Kindly check whether these lines can help you in any means. You may have any issues then please write here,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    6

    Re: Best practices for images and resources files

    Dear Raj,
    thank you for your reply. I'll certainly try pngout.exe to reduce their size. I think too that strings are probably a better option - the use of xml is a hang over from my J2SE development! As for the other static info, it's to be used to store info for a glossary of terms which will contain about 40 terms with definitions - am I better storing these in a class as strings rather than as xml?

    Regards

    Angus

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

    Re: Best practices for images and resources files

    The main problem with XML is parsing it. Nice and easy if you have the XML parsing API, otherwise you need code to do it.

    One option is to "pre-parse" the data. Write a J2SE program to read the XML, that writes out the data in a simpler format, using a DataOutputStream. Use writeUTF(), writeInt(), etc. This file can easily be read in J2ME using a DataInputStream. This means you can still manage your data in XML, if that suits you.

    Quote Originally Posted by Angus Rose View Post
    Would I be better off converting them into byte arrays to increase speed of the application and their rendering?
    An Image object contains a byte array... the PNG (or JPEG or whatever) data is expanded by createImage() into an uncompressed array of pixels. The format of this data will suite the display hardware of the device, to maximize the rendering speed. So, Image objects are about the fastest way you can render.

    One side effect of this you should be aware of is that the uncompressed image data is much bigger than the PNG or JPEG file. Image objects can take an enormous amount of heap. You might want to read this article. This particularly trips up people who develop for a Series 60 device (which will have enormous amounts of memory), and then try to use their app on a Series 40 with much less memory.

    Graham.

Similar Threads

  1. FileConnetion API Reading and Writing Best Practices
    By bvpsarma in forum Mobile Java General
    Replies: 2
    Last Post: 2009-12-20, 12:48
  2. Icon files in S60 3rd MR and Carbide.vs 3.0
    By akrapacs in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2008-01-29, 07:34
  3. Can carbide handle included files in mmp files
    By svdwal in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 4
    Last Post: 2006-12-04, 17:14
  4. using mbm files in resources
    By wojtek1981 in forum Symbian
    Replies: 2
    Last Post: 2006-03-15, 02:03
  5. Standard/Convention for Grouping of files
    By funachan in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2005-06-07, 03:04

Posting Permissions

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