×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Aug 2008
    Location
    Pune
    Posts
    223

    Show imge on canvas

    hi all,
    i am devlope an application related to the downloading image and show this downloaded image on the canvas.
    The image downloaded successfully but it cant display on canvas .
    pls help me ASAP....
    Thanx....

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Show imge on canvas

    Hi devdattac,

    which problem are you encountering with your code? Using the image bytes to create your Image instance and then using Graphics drawImage() method should work.. do you get any Exceptions with it?

    Pit

  3. #3
    Regular Contributor
    Join Date
    Aug 2008
    Location
    Pune
    Posts
    223

    Re: Show imge on canvas

    thanx 4 reply,
    i got error on line ........
    display.setCurrent(canvas);
    where canvas is object of class Canvas

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Show imge on canvas

    Which kind of Exception are you getting? Also, do you properly initialize your display and canvas variables?

    Pit

  5. #5
    Regular Contributor
    Join Date
    Aug 2008
    Location
    Pune
    Posts
    223

    Re: Show imge on canvas

    i got null pointer exception....

  6. #6
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: Show imge on canvas

    I face this kind of problem when i was learning. You please check that are you allocation memory with new or not. I done that thing wrong so check it.

  7. #7
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Show imge on canvas

    If you're getting a NullPointerException on that code line, that it's likely you have not properly initialized your display variable, as told also by honest_success.

    Something like this should be in your code:
    Code:
    display = Display.getDisplay(yourMidletInstance);
    Pit

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

    Re: Show imge on canvas

    that or u are trying to show the canvas object (instanced of Canvas) without having it instantiated to begin with...
    also using the name canvas is very unappropriate, simply because it looks too much as the predefinied class Canvas, call it myCanvas or whatever istead and at some point u will use :

    myCanvas canvasToUse = new myCanvas();
    display.setCurrent(canvasToUse);

    for the myCanvas class ucan start with extending the Canvas class itself :

    class myCanvas extends Canvas

    or

    class myCanvas extends GameCanvas

  9. #9
    Registered User
    Join Date
    May 2007
    Location
    Cordoba, Argentina
    Posts
    17

    Re: Show imge on canvas

    Dear Tiger you can show images in a canvas, you will need to create a class
    /* Frist you need to create your canvas */
    public class yourCanvas extends Canvas { ...
    /* all the magic is in the paint method */
    public void paint(Graphics g){ ...
    /* also you need instansiate yourCanvas */
    yourCanvas = new biGraphCanvas(...);
    /* And finally you need to show as a diplayable */
    display.setCurrent(yourCanvas);

    When I started i used a sample program Hello midlet is just great
    You can show images in an alert too
    I hope it helps you
    Sergio
    Sergio Mabres
    Prominente S.A.
    Argentina

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

    Re: Show imge on canvas

    hehe thx for the input,
    but I didnt have any problems at all...
    The TS has, so I was only trying to help him out...
    guess u misunderstood...

Similar Threads

  1. Show Canvas while keyPressed
    By zidia in forum Mobile Java General
    Replies: 1
    Last Post: 2007-12-01, 09:21
  2. Replies: 2
    Last Post: 2005-12-22, 07:36
  3. Canvas doesn't show when getWidth/getHeight is used
    By claudio4j in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2003-11-05, 08:41
  4. Major problem with delegation to Canvas
    By bartekn in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2003-10-08, 17:46
  5. how to show a canvas after another?
    By lingtze1 in forum Mobile Java General
    Replies: 1
    Last Post: 2003-06-10, 12:29

Posting Permissions

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