Discussion Board

Results 1 to 3 of 3

Thread: image loading

  1. #1
    Registered User csergiu77's Avatar
    Join Date
    Jan 2009
    Posts
    10
    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
    Nokia Developer Champion Tiger79's Avatar
    Join Date
    Apr 2007
    Posts
    2,697
    well the S60's are symbian and they run a KVM, whilst the series 40 are native java ?
    thats just me guessing...

  3. #3
    Registered User grahamhughes's Avatar
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,394
    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. Theme Studio 3.1 not creating themes
    By zemm in forum Themes/Carbide.ui
    Replies: 11
    Last Post: 2008-10-18, 08:41
  2. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  3. 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
  4. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31
  5. 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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved