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


Try to save the text, images and the whole drawing as objects and when the user clicks the save button, create a new bitmap with the required resolution and translate the current canvas to the required one



+1


source


I think this is due to the use of bitmap.compress (CompressFormat.JPEG, 100, ostream); use png for jpeg Hope you're ok.



0


source







All Articles