> Hi. I have a problem with saving canvas to file. All over net there
> are faqs on how to save a NEW canvas to file (after drawing on it). I
> have a canvas, what should i do in order to save what's currently on
> it to a file?

Signature
Knute Johnson
email s/nospam/knute/
On 29 Lip, 19:24, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
> > Hi. I have a problem with saving canvas to file. All over net there
> > are faqs on how to save a NEW canvas to file (after drawing on it). I
[quoted text clipped - 12 lines]
> Knute Johnson
> email s/nospam/knute/
I've noticed a lot of examples in the web on how to save bufferedimage
to file, which, in answer to Your question, is my goal. I just wanted
to find out if there is any way of saving the image directly from
canvas. Thank You for Your answer.
Roedy Green - 29 Jul 2007 19:45 GMT
>I've noticed a lot of examples in the web on how to save bufferedimage
>to file, which, in answer to Your question, is my goal. I just wanted
>to find out if there is any way of saving the image directly from
>canvas. Thank You for Your answer.
You could screen scrape to capture the bits on the screen.
See http://mindprod.com/jgloss/screenscraping.html

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Knute Johnson - 29 Jul 2007 19:52 GMT
> On 29 Lip, 19:24, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
> wrote:
[quoted text clipped - 18 lines]
> to find out if there is any way of saving the image directly from
> canvas. Thank You for Your answer.
If the only drawing on your Canvas is done in the paint() method you
could use that method to draw onto the BufferedImage. The technique
would be to get a draw Graphics for the BufferedImage and then call
paint() with that Graphics. If your drawing is going to be from user
interaction then using the BufferedImage as your drawing surface and
displaying that to the user makes more sense. Of course in the first
case above, serializing the Canvas would work too.

Signature
Knute Johnson
email s/nospam/knute/
Roedy Green - 30 Jul 2007 11:33 GMT
>Of course in the first
>case above, serializing the Canvas would work too.
I suspect that a serialised Canvas could not be reconstituted in a
different machine. I think it will be specific to the screen hardware.
I know Image has this problem.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Knute Johnson - 30 Jul 2007 18:01 GMT
>> Of course in the first
>> case above, serializing the Canvas would work too.
> I suspect that a serialised Canvas could not be reconstituted in a
> different machine. I think it will be specific to the screen hardware.
> I know Image has this problem.
In a serialized object all that gets stored are the fields. The data to
recreate the drawing would have to be stored in fields in the Canvas.
The actual drawing surface would be lost. I need to play with this some
but I've got to go to work this week. If I have time I'll post
something from the road :-). Interesting possibilities though.

Signature
Knute Johnson
email s/nospam/knute/