• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to save a Path & Paint object to file.

 
tien lq
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic