×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Feb 2012
    Posts
    60

    Drawing Rect on Image

    hi,

    Is there any way to draw to Rectangle on image in canvas.

    reply as early as possible.thanks

  2. #2
    Regular Contributor
    Join Date
    Dec 2011
    Posts
    174

    Re: Drawing Rect on Image

    Hi rana.anees,

    Yes it is possible. Below a code snippet how to draw a rectancle on a mutable image.

    Code:
    Image newImage,sourceImage;
    
    public void initializeImage()
    {
    	try {
    		 sourceImage = Image.createImage("/image.png");
    	     } catch (IOException e) {}
    	
    	 newImage = Image.createImage(sourceImage.getWidth(),sourceImage.getHeight());
    	 
    	 Graphics imageGraphics = newImage.getGraphics();
    	 imageGraphics.drawImage(sourceImage, 0, 0, 0);
    	 imageGraphics.setColor(0xff0000);
    	 imageGraphics.fillRect(10, 10, 40,40);
    		 
    	 sourceImage= null;
    }
    	
    protected void paint(Graphics g)
    {
    	g.drawImage(newImage,55,55,0);
    }
    Regards,
    tiviinik

  3. #3
    Regular Contributor
    Join Date
    Feb 2012
    Posts
    60

    Re: Drawing Rect on Image

    thanks for reply.one more question can we use key press Fuction class which is extended from form
    Last edited by rana.anees; 2012-02-17 at 09:38.

  4. #4
    Regular Contributor
    Join Date
    Dec 2011
    Posts
    174

    Re: Drawing Rect on Image

    Hi rana.anees,

    If you mean the Displayable and command actions yes they can be used with a form. If you want to receive key and pointer events directly you would have to use a Canvas.

    -tiviinik

Similar Threads

  1. Drawing SVG image on a transparent mutable Image
    By mkonji in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2010-09-29, 07:14
  2. Canvas: How to draw a Rect around an image?
    By ricardopcunha in forum Mobile Java General
    Replies: 2
    Last Post: 2009-02-10, 17:34
  3. Drawing Lines on an Image (image graphics object returns null)
    By nicenouman in forum Mobile Java General
    Replies: 4
    Last Post: 2006-09-21, 10:15
  4. How to resize the image to a given rect region
    By TeachMe in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2006-04-13, 14:08
  5. Series 40 - image resizeing and drawing black and white only a part of an image
    By ionutianasi in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2003-07-21, 10:36

Posting Permissions

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