Android - Save image in full resolution file

I put the image inside the ImageView and implemented multi-touch to resize and move the image inside the ImageView. Now I need to save the modified image to an image file. I tried .getDrawingCache (), but this image is ImageView size. I want the image to show what ImageView shows, but with full resolution (more than ImageView).

Any ideas?

+4
source share
2 answers

My solution was to use the matrix that I used for ImageView to get the translation, and I also had the scale of this image. Using these two, I cropped the original image.

Bitmap resizedBitmap = Bitmap.createBitmap( BitmapFrontCover, (int) UpperLeftCornerX, (int) UpperLeftCornerY, (int) CropWidth, (int) CropHeight); 
0
source

You can save the Bitmap object in the background, which you can change using this piece of code:

 Matrix matrix = new Matrix(); matrix.postScale(scaledWidth, scaledHeight); Bitmap resizedBitmap = Bitmap.createBitmap(originalBitmap, 0, 0, originalBitmap.width(), originalBitmap.height(), matrix, true); 

And save it later using this code:

 OutputStream fOut = null; File file = new File(strDirectoy,imgname); fOut = new FileOutputStream(file); resizedBitmap.compress(Bitmap.CompressFormat.PNG, 0, fOut); fOut.flush(); fOut.close(); 
+4
source

Source: https://habr.com/ru/post/1388111/


All Articles