Closed ghost closed 9 years ago
Good note, will add it in today
Hello Just got home and wrote this method to retrieve current drawing as a Bitmap. getCanvasBitmap() You can check out other resources such as this question to see how you can save a bitmap! http://stackoverflow.com/questions/15662258/how-to-save-a-bitmap-on-internal-storage
great! Thanks
do you have source code code for the app show in the animated GIF in Sample Screen Recording?
No :( it was something I scrapped together on a computer in school and deleted later due to space issues there). I'll put together another one this weekend and upload it
Thanks! I have write following code to save FabricView as png. The result of png has transparent background, are there anyway to set initial fabricView background color or image? I tried the FabricView.setBackgroundColor(getColor(R.color.white)), it doesn't work, it still return transparent background png
final FabricView fabricView = (FabricView) findViewById(R.id.drawView); fabricView.setStyle(Paint.Style.STROKE); fabricView.setSize(UnitHelper.DIP2Pixel(this, 4));
findViewById(R.id.commit).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
File file = getFileBackend().getTempFile("png");
FileOutputStream fos = new FileOutputStream(file);
fabricView.getCanvasBitmap().compress(Bitmap.CompressFormat.PNG, 90, fos);
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
});
I am able to covert the transparent background bitmap to white background using following sample code:
FileOutputStream fos = new FileOutputStream(file); Bitmap drawBmp = fabricView.getCanvasBitmap(); Bitmap newBmp = Bitmap.createBitmap(drawBmp.getWidth(), drawBmp.getHeight(), drawBmp.getConfig()); Canvas canvas = new Canvas(newBmp); canvas.drawColor(Color.WHITE); canvas.drawBitmap(drawBmp, 0, 0, null); newBmp.compress(Bitmap.CompressFormat.PNG, 90, fos); fos.close();
Glad you got it working!
would be nice we could save draw result as image file