Saving canvas image in high resolution
I am creating an Android application where the user can draw, add text or image to the canvas. After the user has finished editing on the canvas, there is an option to save. When I try to save this as an image, the resulting output image is of a very low resolution.
canvas.setDrawingCacheEnabled(true);
canvas.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
Bitmap bitmap = canvas.getDrawingCache();
String path = Environment.getExternalStorageDirectory().getAbsolutePath();
File file = new File(path+"/image.jpg");
FileOutputStream ostream;
try {
file.createNewFigle();
ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.JPEG, 100, ostream);
ostream.flush();
ostream.close();
Toast.makeText(getApplicationContext(), "image saved", 5000).show();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), "error", 5000).show();
}
I want the image to be saved as A3 300dpi. Is there a way?
+3
source to share
2 answers