×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Sep 2009
    Location
    Bangalore, India
    Posts
    49

    Post Capturing and saving canvas drawings..

    Hi,
    Everyone.. I have a canvas with has some options of drawing tools.. like freehand drawing.. And even it has option of opening the image of bigger size. (i mean bigger then canvas size..) .. I have implemented scroll option for the same..

    Is there any option to capture the image (full sized image) and the drawn graphics from the screen....


    Please guys help me for the same..
    Regards
    Nilanchala

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

    Re: Capturing and saving canvas drawings..

    Welcome to Forum Nokia!

    Create an image:

    Code:
    Image buffer = Image.createImage(width, height);
    and draw to that. Then, in the Canvas's paint() method, draw the "buffer" image to the canvas. That way, there's no need to capture it, because you already have it.

    Graham.

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

    Re: Capturing and saving canvas drawings..

    Quote Originally Posted by nilanchalapanigrahy View Post
    Hi,

    Is there any option to capture the image (full sized image) and the drawn graphics from the screen....


    Please guys help me for the same..
    As Graham suggested, first create an image of the size you want by -- Image buffer = Image.createImage(width, height);
    Then get a instance of Graphics g from it --> Graphics gg=buffer.getGraphics();
    Now paint everything, run all your application logic with this gg instead of your full Canvas g
    do all gg.drawImage(),gg.drawLine(),gg.drawString() etc... all Canvas Paint operation on this Image and then finally paint this Image buffer on the full Canvas.

    So now you will have the copy of everything visible on the canvas in your buffer Image...and can save it if needed.
    Thanks,
    Ekta

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

    Re: Capturing and saving canvas drawings..

    Hi Ektasrv,

    As per the solution that you have provided we can capture the visible area elements only...
    But if we have implemented a scroll bar then few things may me beyond the visible region.. what to do in that case.. can we capture and save those elements ???

    Anyways thanks in advance....
    Regards
    Nilanchala

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

    Re: Capturing and saving canvas drawings..

    Quote Originally Posted by nilanchalapanigrahy View Post
    Hi Ektasrv,

    As per the solution that you have provided we can capture the visible area elements only...
    But if we have implemented a scroll bar then few things may me beyond the visible region.. what to do in that case.. can we capture and save those elements ???

    Anyways thanks in advance....
    You can capture the entire Image on which you are drawing - may it be of any size.
    Image buffer = Image.createImage(width, height); // here you can give size bigger then The Canvas, scroll it all over and modify it by taking the graphics object from it and drawing/painting over it.
    Now you paint the buffer image on the Canvas such that you display the portion of this image on the Canvas which the user wants to view and edit.
    So your buffer Image is full Image what ever the user has created and you can capture or save it complete or even give the user options to select a particular portion of the full image using createImage(Image buffer, int x, int y, int width, int height, int transform)
    Thanks,
    Ekta

Similar Threads

  1. Canvas: How to show only a image not a canvas background
    By ricardopcunha in forum Mobile Java General
    Replies: 13
    Last Post: 2009-02-16, 08:59
  2. Clear drawings on image
    By kenneth@hrensberg.dk in forum Symbian
    Replies: 3
    Last Post: 2008-05-10, 20:25
  3. How to create a partly transparent Canvas to lay on top of another Canvas?
    By mkleijer in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2007-05-22, 07:00
  4. 6310i CAD Drawings?
    By alspa in forum General Development Questions
    Replies: 2
    Last Post: 2006-05-19, 04:10
  5. Replies: 2
    Last Post: 2006-03-08, 11: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
  •  
×