2

hello guys i'm having a problem with scaling an image to square size. 612 * 612

first i'm getting the image as cache from the imageview and then i'm converting it to Bitmap image.

    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    save = view.getDrawingCache();

then i'm using Bitmap.createScaledBitmap as below

     Bitmap a = Bitmap.createScaledBitmap(save, 612, 612, true);

it works as i want it but when the image scaled it lose its quality

here is how i compress the image to save it / share it

        a.compress(Bitmap.CompressFormat.PNG, 100, out);

i'm sharing it through my application to Instagram to fit inside instagram cropping tool but the image always will be low quality. can anyone tell me how do i scale / resize the image dimension without losing its quality or to fit inside instagram cropping tool without losing quality. thanks

Kosh
  • 5,883
  • 2
  • 34
  • 67

1 Answers1

0

If you scale the bitmap you lose quality as well . what i prefer You can use BitmapFactory

BitmapFactory.Options option = new BitmapFactory.Options();
        option.inJustDecodeBounds = true;

        option.inSampleSize = 4;
Bitmap bm = BitmapFactory.decodeFile(root.getPath() + "/" + imageName, option);

refer below links for more details

this this this this

Community
  • 1
  • 1
Sachin Gurnani
  • 4,421
  • 9
  • 41
  • 48
  • i'm saving the image after the user edit it on my app !! why do i need to decode the file again ? that will save the image as it comes !!!! not the edited image. – Kosh Apr 07 '13 at 16:28