I put an image inside an ImageView and have multitouch implemented to resize and move the image inside the ImageView. Now I need to save the resized image to a image file. I have tried the .getDrawingCache() but that image have the size of the ImageView. I want the image to show what the ImageView shows but with full resolution (larger than the ImageView).
Any ideas?
You could hold a Bitmap Object in Background, which you can resize with 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();
My solution was to use the matrix that I used for the ImageView to get the translation and I also had the scale of that image. Using those two I cropped the original image.
Bitmap resizedBitmap = Bitmap.createBitmap(
BitmapFrontCover, (int) UpperLeftCornerX,
(int) UpperLeftCornerY, (int) CropWidth,
(int) CropHeight);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With