×

Discussion Board

Results 1 to 8 of 8

Hybrid View

  1. #1
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    80

    slow update of canvas - 30s wait

    i developed an application that draw square on a canvas. after some algorithm, the location of the square is moved. i need to draw the new location of that square on the same canvas. however, when i use the repaint() command, i need to wait around 30s for the canvas to be updated. why is this? is this normal? if it isnt, why is it behaviour this way?

    please help

  2. #2
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: slow update of canvas - 30s wait

    Hi this is not normal have u used sleep in your code also is it happening on device or simulator if device what device u r using

    Also a snap of your code will be more helpful to solve out your problem
    Regards,
    Saurabh

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

    Re: slow update of canvas - 30s wait

    also are you creating a multi-threaded application ?

  4. #4
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    80

    Re: slow update of canvas - 30s wait

    public class testFirstAppTwo extends MIDlet implements CommandListener{

    private AppCanvas testAppCanvas;
    private Display display;
    private Command exit,start,stop;

    private Player player;
    private VideoControl control;

    private byte[] raw = null;
    private byte[] raw2 = null;
    private Image image=null;
    private Image image2=null;


    public testFirstAppTwo(){
    exit = new Command("Exit", Command.EXIT, 0);
    start = new Command("Start", Command.SCREEN, 0);
    stop = new Command("Stop", Command.SCREEN, 0);
    }

    public void startApp() {
    testAppCanvas = new AppCanvas();
    testAppCanvas.addCommand(exit);
    testAppCanvas.addCommand(start);
    testAppCanvas.setCommandListener(this);

    display = Display.getDisplay(this);
    display.setCurrent(testAppCanvas);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable arg1) {
    if(c == start)
    {
    startVideoThread();
    }
    else if(c == exit)
    {
    destroyApp(true);
    notifyDestroyed();
    }
    else if (c == stop)
    {
    }
    }

    public void startVideoThread(){
    try
    {
    player = Manager.createPlayer("capture://video");
    player.realize();
    control = (VideoControl)player.getControl("VideoControl");
    control.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,Display.getDisplay(this).getCurrent());
    control.setVisible(false);
    player.start();
    }
    catch(Exception e)
    {
    }

    try
    {
    raw = control.getSnapshot("encoding=bmp");
    image = Image.createImage(raw, 0, raw.length);
    raw2 = control.getSnapshot("encoding=bmp");
    image2 = Image.createImage(raw2, 0, raw2.length);


    // some processing is done here

    cuMVx=(cuMVx+vH)/2;
    cuMVy=(cuMVy+vV)/2;


    int x = testAppCanvas.positionX; int newPosX = cuMVx+x;
    int y = testAppCanvas.positionY; int newPosY = cuMVy+y;
    testAppCanvas.change(newPosX,newPosY);

    Display.getDisplay(this).setCurrent(testAppCanvas);
    }
    catch(Exception exc)
    {
    }
    player.close();
    player = null;
    control = null;
    }
    }

    public class AppCanvas extends Canvas{

    public int randomW,randomV;
    public int positionX, positionY;

    private int canvasWidth,canvasHeight;


    public AppCanvas(){
    Initialize();
    }

    private void Initialize(){

    positionX = 30; positionY = getHeight()/2;
    randomW = 100; randomV = getHeight()/2;

    }
    protected void paint(Graphics g) {
    g.setColor(0x000000);
    g.fillRect(randomW,randomV,40,40);
    g.setColor(0x0000ff);
    g.fillRect(positionX,positionY,40,40);

    }

    public void change(int x, int y){
    positionX = x;
    positionY = y;
    repaint();
    }
    }

    The code is as above. Please advise. No, i dont run multi-threading.

  5. #5
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    80

    Re: slow update of canvas - 30s wait

    btw, i am using N96. from specification SDK for N96 is s60 feature pack 2. I couldnt find s60 feature pack 2 to download. I think nokia discontinue it. So for my development i use s60 feature pack 1. Does it affect the slowness, somehow?

  6. #6
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: slow update of canvas - 30s wait

    Till now every app that I made if uses canvas runs in thread for repaintaing the canvas again and again which is not in your case I suggest to use thread for your canvas class and repaint the canvas in that thread.
    Regards,
    Saurabh

Similar Threads

  1. How do i update the icon on my Wait dialog at run time?
    By itsbharatk in forum Symbian User Interface
    Replies: 6
    Last Post: 2009-01-21, 06:47
  2. [moved] " SOFTWARE UPDATE FAILED "
    By musum in forum General Development Questions
    Replies: 1
    Last Post: 2008-06-01, 08:04
  3. [announce] wait dialog wrapper 0.2
    By lfd in forum Symbian
    Replies: 10
    Last Post: 2008-03-21, 11:03
  4. How To Incorporate A Wait Note With A BlueTooth Service Discovery?
    By Mo7ammed_01 in forum Bluetooth Technology
    Replies: 2
    Last Post: 2006-07-14, 08:22
  5. Replies: 4
    Last Post: 2005-11-10, 06:13

Posting Permissions

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