×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    17

    How to store/compress image data so that I can access small bits at a time?

    Hi,

    What's the best way to compress and/or store image data so my J2ME midlet can access just small bits of the image without having to decompress the whole large image? (i.e. random access to small parts of compressed data - in this case image data)

    I'm going to have various big image font files (i.e. an image with all the characters of certain languages laid out in grid format so I can render my own font on the Canvas) and I want to obviously get the individual character images off that to lay on the screen. I know about the general technique of using clipping for this, so no problems there. But the font image for certain languages will be big (from a few hundred to few thousand characters). I can't use Unicode and the built in fonts in the phone for various reasons I won't bother you with here.

    So, is there some way of storing image data (PNG, or raw RGB, or any other format, even a custom format) that means I can pull out of the big data chunk just the character image data I want, without Java Mobile loading the whole image (or data) in to memory first? Part of the reason for this is it will be running on low end older phones with less memory and CPU.

    So far I considered:
    1.) Split large font image into several smaller images. Trouble is how many characters per image, and selecting quickly from the different smaller images without loading each one into memory and discarding it again, for every character.

    2.) Use RGB data which is obviously very big for uncompressed image data, but zip-compress the data and then unzip bits I want using TinyLine's GZipInputStream http://tinyline.com/utils/index.html
    Problem with this is presumably due to the zip algorithm it needs to get the whole data file in memory to unzip any part of it?
    Also processor overhead in decompression and converting RGB data to J2ME Image.

    The font image as a whole will be stored either on filesystem, or in RMS, or as a resource in the JAR.

    Many thanks for any suggestions etc!

    Alex
    Last edited by alexkerr; 2011-03-01 at 17:14.

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

    Re: How to store/compress image data so that I can access small bits at a time?

    Quote Originally Posted by alexkerr View Post
    1.) Split large font image into several smaller images. Trouble is how many characters per image, and selecting quickly from the different smaller images without loading each one into memory and discarding it again, for every character.
    This is worth considering. How about you load the compressed PNGs into memory using getResourceAsStream() into byte[]s, and create the images from the byte[]s as you need them? Faster than loading them, but it's still going to be a slow way to render text. Consider a cache (perhaps using WeakReferences) to keep as many decompressed images as you can.

    Graham.

Similar Threads

  1. How to store settings so that they survice reinstalls or updates?
    By oxidative in forum Symbian Web Runtime
    Replies: 2
    Last Post: 2010-03-01, 17:04
  2. how to write files so that nm.exe can read them?
    By weidberg in forum General Development Questions
    Replies: 2
    Last Post: 2009-10-12, 11:02
  3. how to read image and text data at a time from the server
    By Basu in forum Mobile Java General
    Replies: 2
    Last Post: 2007-11-14, 19:34
  4. Replies: 0
    Last Post: 2005-04-12, 07:25
  5. Replies: 0
    Last Post: 2004-10-03, 07: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
  •