How to save current state of canvas as an image in android -
i'm developing application allows user edit image , save edited image new image on sd card want current state of canvas object. please me this.
it's hard answer without knowing more how image editor works. guess surfaceview, commonly subclassed allow arbitrary drawing.
surfaceview provides easy way render output canvas , 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); }
Comments
Post a Comment