I was reading an answer to a different question on SO, in which @RomainGuy commented that one could (please correct me if I\'m paraphrasing incorrectly) back-port code from
You should consider BitmapRegionDecoderCompat, an API 8+ version of the standard BitmapRegionDecoder (API 10+).
decodeBestRegion(),
which extracts the "best" image subregion given your parameters (gravity, size). This method also works on API < 10.In order to use it in your project you can manually download and add the library as an AAR file:
or you can add the dependecy in your build.gradle (requires jCenter repository):
dependencies {
//...your dependecies
compile 'org.bonnyfone:brdcompat:0.1'
}
As stated in the docs, in order to migrate to BRDCompat you just need to change the base class name from BitmapRegionDecoder to BitmapRegionDecoderCompat:
//BitmapRegionDecoder brd = BitmapRegionDecoder.newInstance(...);
BitmapRegionDecoderCompat brd = BitmapRegionDecoderCompat.newInstance(...);