×

Discussion Board

Results 1 to 3 of 3

Thread: image loading

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    10

    Post image loading

    I work on application that among other things download some images from a server.

    Strange but on nokia 6233 images are loaded quite fast 2,3 sec.

    N73 - 85-90 sec
    E61 - 110 sec (using 3G)
    E51 - 25-30 sec (using wireless)
    E51 - 35-55 sec (3G connection)


    On any SE i tried it works very very fast ,almost instant loading !!!!

    ANy ideea why ?

  2. #2
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: image loading

    well the S60's are symbian and they run a KVM, whilst the series 40 are native java ?
    thats just me guessing...

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

    Re: image loading

    It may depend on your code.

    Reading one byte at a time tends to be really slow on some devices.

    Code:
    public static byte[] read(InputStream in, int contentLength) throws IOException {
        byte[] b = new byte[contentLength];
        for (int i = 0; i < contentLength; i++) {
            // don't do this!  Slow!!
            b[i] = (byte)in.read();
        }
        return b;
    }
    Reading into an array is much better. Note that you can't just call read() and expect everything to be OK. You must check the return value to see how many bytes were actually read.

    Code:
    public static byte[] read(InputStream in, int contentLength) throws IOException {
        byte[] b = new byte[contentLength];
        int readSoFar = 0;
        while (readSoFar < contentLength) {
            readSoFar += in.read(b, readSoFar, contentLength - readSoFar);
        }
        return b;
    }
    I'm surprised this would make S60's slower, but if you're using code like the first example, you should definitely switch.

    (The same applies to reading resource files from the JAR.)

    Cheers,
    Graham.

Similar Threads

  1. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  2. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05
  3. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31
  4. Loading Image data from 'raw' bytes
    By LongSteve in forum Mobile Java General
    Replies: 2
    Last Post: 2002-11-20, 17:38

Posting Permissions

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