wood burning stoves 2.0*
The moose likes Android and the fly likes How to save a Path & Paint object to file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "How to save a Path & Paint object to file." Watch "How to save a Path & Paint object to file." New topic
Author

How to save a Path & Paint object to file.

tien lq
Greenhorn

Joined: Dec 31, 2010
Posts: 1
Hi everyone,

Now I'm using canvas.drawPath(Path path, Paint paint) to draw a path
which is created by user with a specified paint.
And before closing this app ( like PhotoShop app), I want to save this
Path and Paint. For the next time. So, user can start at their
previous canvas(screen).

Some said that they should be converted to bytearray [] and use
FileOutputStream to write it to file.
But I don't know how to do that.

Please, help me. I really really need your advice.
Thanks so much.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Assuming that you created a bitmap for the canvas to draw into, you could use the Bitmap.compress() method to write the bitmap to a file.

http://developer.android.com/reference/android/graphics/Bitmap.html#compress(android.graphics.Bitmap.CompressFormat,%20int,%20java.io.OutputStream)


JBoss In Action
 
Don't get me started about those stupid light bulbs.
 
subject: How to save a Path & Paint object to file.