This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 5772
    
    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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to save a Path & Paint object to file.
 
Similar Threads
IE 5.5 and 6.0 - Saving Images - BMP only
Selecting a directory instead a file
Using Properties File to set database path
problem in unzipping
Alternative to MS Paint