×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Aug 2009
    Location
    Iran - Tabriz
    Posts
    111

    why this code run very slowly on nokia device

    Hi
    please look this code , when i run it on nokia N97 it`s run very slow but i test it on samsung corby it`s run true , i think if i use game canvas problem be sloved . what should i do to solve this problem .

    Code:
    /*
    
    
    import java.io.IOException;
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.game.GameCanvas;
    
    /**
     * @author mahdi
     */
    public class MIDPCanvas extends GameCanvas implements Runnable {
    
        Graphics g;
        Image img;
        int x = getWidth() / 2;
        Thread t = new Thread(this);
    
        public MIDPCanvas() {
            super(true);
    
            try {
                img = Image.createImage("/pic.jpg");
            } catch (IOException ex) {
                ex.printStackTrace();
            }
    
            g = getGraphics();
            g.setColor(150, 230, 200);
            g.fillRect(0, 0, getWidth(), getHeight());
    
            t.start();
        }
    
        public void run() {
            while (true) {
                g.drawImage(img, x, getHeight() / 2, Graphics.VCENTER | Graphics.HCENTER);
                x--;
                flushGraphics();
            }
        }
    }
    thanks

  2. #2
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: why this code run very slowly on nokia device

    I'm curious as to what happens when "x" goes negative.

  3. #3
    Regular Contributor
    Join Date
    Aug 2009
    Location
    Iran - Tabriz
    Posts
    111

    Re: why this code run very slowly on nokia device

    Quote Originally Posted by danhicksbyron View Post
    I'm curious as to what happens when "x" goes negative.
    x is an image with 3654 pixels width , image move from right position of lcd to left and show image

  4. #4
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: why this code run very slowly on nokia device

    You realize, don't you, that the code you have there is compute-bound, with nothing to terminate it or make it "come up for air". Not a phone-friendly design.

  5. #5
    Regular Contributor
    Join Date
    Aug 2009
    Location
    Iran - Tabriz
    Posts
    111

    Re: why this code run very slowly on nokia device

    Quote Originally Posted by danhicksbyron View Post
    You realize, don't you, that the code you have there is compute-bound, with nothing to terminate it or make it "come up for air". Not a phone-friendly design.
    What method do you recommend ؟

Similar Threads

  1. Midlets run very slowly on firmware v21 on N97
    By Larry101 in forum Mobile Java General
    Replies: 2
    Last Post: 2010-02-12, 05:49
  2. Code that calls a program to run when the device is called
    By highwoods in forum Mobile Java General
    Replies: 1
    Last Post: 2008-07-21, 11:57
  3. Playing mp3 slowly on s60 fp2 device
    By bellshine in forum Symbian Media (Closed)
    Replies: 4
    Last Post: 2008-01-23, 05:15
  4. Code not run on nokia 6600
    By textel in forum Mobile Java General
    Replies: 4
    Last Post: 2005-07-12, 21:18
  5. easy code can't run in NOKIA !
    By mayongfeng in forum Mobile Java General
    Replies: 1
    Last Post: 2004-08-19, 08:34

Posting Permissions

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