×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    37

    Thumbs down How to create image using Canvas without using imageitem and graphics.drawimage?

    Hi,

    I want to create an image( a Round Rectangle with text on it with specific font, round rectangle filled half with light color and half with dark color) using canvas but without using imageitem class or graphics.drawimage method.

    Can you please give me code for this or any ideas on how to do this?
    Mayur Dharukiya
    WWW.MAYURDHARUKIYA.COM
    J2ME Team Lead at eTechnolabs.com
    Symbian S60 Ambassador
    Nokia Pilot

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

    Re: How to create image using Canvas without using imageitem and graphics.drawimage?

    Have you looked at the methods of the Graphics class, for the various things you can draw in the Canvas's paint() method? There are methods for drawing rectangles, text, setting font and colour, etc.

    Graham.

  3. #3
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: How to create image using Canvas without using imageitem and graphics.drawimage?

    Quote Originally Posted by kalki View Post
    Hi,

    I want to create an image( a Round Rectangle with text on it with specific font, round rectangle filled half with light color and half with dark color) using canvas but without using imageitem class or graphics.drawimage method.

    Can you please give me code for this or any ideas on how to do this?
    There are two method by which you can do this.

    1.You design and get ready the image using the photoshop as per your requirement of the Font, style and look and feel as a Round Rectangle with text on it with specific font, round rectangle filled half with light color and half with dark color...make sure that the extension is PNG
    Put the image in res folder and then load the image using the Image class and Image.createImage()..and draw same on the canvas.

    2.You do all the things by youself like the a Round Rectangle with text on it with specific font, round rectangle filled half with light color and half with dark color and then simple keep on painting on the canvas.

    I hope these lines helps you.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  4. #4
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: How to create image using Canvas without using imageitem and graphics.drawimage?

    Quote Originally Posted by kalki View Post
    Hi,

    I want to create an image( a Round Rectangle with text on it with specific font, round rectangle filled half with light color and half with dark color) using canvas but without using imageitem class or graphics.drawimage method.

    Can you please give me code for this or any ideas on how to do this?
    use setColor(light color);
    g.fillRoundRect();
    setColor(drak color);
    g.fillRoundRect();
    setColor(text color);
    g.drawString("text");
    Thanks,
    Ekta

  5. #5
    Registered User
    Join Date
    Sep 2009
    Location
    Bangalore, India
    Posts
    49

    Lightbulb Re: How to create image using Canvas without using imageitem and graphics.drawimage?

    Quote Originally Posted by ektasrv View Post
    use setColor(light color);
    g.fillRoundRect();
    setColor(drak color);
    g.fillRoundRect();
    setColor(text color);
    g.drawString("text");
    As Ekta said earlier, Once you have done with the graphics in your canvas. You can create image using. It will create an mutable image for you..

    PHP Code:
    Image image Image.createImage(getHeight(), getHeight());
    Graphics g image .getGraphics();
    paint(g); 
    Regards
    Nilanchala

  6. #6
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: How to create image using Canvas without using imageitem and graphics.drawimage?

    If you want to draw all this rectangle etc on a Image, you first need to create an Image, then fetch the graphics context from it and then draw on it using this graphics context as under:
    Code:
    Image image = Image.createImage(getHeight(), getHeight()); 
    Graphics g = image.getGraphics();
    setColor(light color);
    g.fillRoundRect();
    setColor(drak color);
    g.fillRoundRect();
    setColor(text color);
    g.drawString("text");
    Thanks,
    Ekta

Similar Threads

  1. Applying Graphics to Canvas used for Image capture
    By sepanaho in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2010-01-13, 11:30
  2. how to create Image from Graphics
    By afka in forum Mobile Java General
    Replies: 1
    Last Post: 2006-09-03, 01:29
  3. Graphics.drawImage() vs DirectGraphics.drawImage()
    By owcs in forum Mobile Java Media (Graphics & Sounds)
    Replies: 11
    Last Post: 2003-11-18, 14:44
  4. Graphics.drawImage and DirectGraphics.drawPixels
    By mrgasjs in forum Mobile Java General
    Replies: 0
    Last Post: 2002-10-23, 01:26
  5. Graphics.drawImage and DirectGraphics.drawPixels
    By mrgasjs in forum Mobile Java General
    Replies: 1
    Last Post: 2002-09-25, 08:49

Posting Permissions

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