I'm developing an application which allows user to edit an image and save that edited image as new image on 开发者_如何学Gosd card I want to get the current state of the canvas object. please help me with this.
It's hard to answer without knowing more about how your image editor works. I will guess that it is a SurfaceView, which is commonly subclassed to allow arbitrary drawing.
SurfaceView provides an easy way to render the output to canvas and thus a bitmap.
Bitmap bitmap = Bitmap.createBitmap(mSurfaceView.getWidth(), mSurfaceView.getHeight(), Bitmap.Config.ARGB_8888);
mSurfaceView.draw(new Canvas(bitmap));
try {
OutputStream out = new BufferedOutputStream(new FileOutputStream(saved.png));
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
} catch (IOException e) {
Log.w(TAG, e);
}
精彩评论