-1

I'm loading an image in to a number of different ImageViews, each with different ScaleTypes. Additionally, some images can be rotated using a Glide transformation before being displayed.

I'd like to be able to make a copy of the original image and crop, rotate, resize it in the same way as it is displayed in the ImageViews.

At the moment I'm grabbing a Bitmap from the ImageView itself but the quality is obviously much lower than the original source image.

Is there a way that I could use the properties of this bitmap and apply them to the original image?

2 Answers2

0

For saving file you can do this

    FileOutputStream out = null;
try {
    out = new FileOutputStream(filename);
    bmp.compress(Bitmap.CompressFormat.PNG, 100, out); // bmp is your Bitmap instance
    // PNG is a lossless format, the compression factor (100) is ignored
} catch (Exception e) {
    e.printStackTrace();
} finally {
    try {
        if (out != null) {
            out.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

the original answer is here

For your rotating, cropping, resizing image, you can use canvas and matrix Android APIs. Here is an answer

And here is Canvas API

vikas kumar
  • 10,447
  • 2
  • 46
  • 52
  • Yes but how would I rotate, crop and resize it to match how it is displayed in the imageview? – Maths Dummy Dec 16 '17 at 16:28
  • if you had posted some code then we could look into it but i have given a link which is also easy to do just create a class and extend from View and then in onDraw() you are suppose to use those methods posted in answer linked. – vikas kumar Dec 16 '17 at 16:33
0

If you are doing that too often in your app, then maybe you are using the wrong library. Please refer this post for more info. https://medium.com/@multidots/glide-vs-picasso-930eed42b81d

Saran Sankaran
  • 2,335
  • 2
  • 19
  • 34