1

Because the inSampleSize of the BitmapFactory.Options is an integer some of my bitmaps get "shrinked" too much. inSampleSize should be something around 1,6 but because it is an int it goes up to 2. Is there any way to convert this inSampleSize to a float?

Some code I use for this:

    float heightRatio = (float) Math.ceil(bmpFactoryOptions.outHeight / (float) height);
    bmpFactoryOptions.inSampleSize = (int) heightRatio;
    bitmap = BitmapFactory.decodeFile(file, bmpFactoryOptions);
L3n95
  • 1,505
  • 3
  • 25
  • 49
  • Nope, that's the way the API was created, until it changes you have to work with it as an Integer. – Dave Sep 15 '14 at 18:28

1 Answers1

3

No, inSampleSize should be power of 2, other values will be ignored. You can find more info in this DevBytes video. Nonetheless you can use this workaround.

Community
  • 1
  • 1
Bracadabra
  • 3,609
  • 3
  • 26
  • 46