Epic Bitmap Renderer, the outOfMemoryError slayer
Decoding and showing images can be a tedious process for an Android developer, full of repetitive tasks you must perform every single time you develop an app in order for it to have a nice performance and avoid those annoying outOfMemoryError.
Following Android development guidelines (see Displaying bitmaps efficiently on Android guide for more info), this 100% free, open source Android Bitmap Decoding library puts an end to these problems, automatizing most of these annoying tasks, and even others you didn't know you had to do!
Features
Open Source and 100% free
Epic Bitmap Renderer is a free, open source Android library protected by an Apache 2.0 license, which means that you can use it in your personal and commercial projects, free of charge, and even modify it to fit your needs, as long as you share and respect the license and original attributions.
Show images from virtually any source
Decode and show images from URLs, app resources, device files, etc. This library can render and display images on your Android app from practically any source. If the render method you are looking for doesn't exist yet, you can create it yourself, as this library is open source, or make a feature request on the Project's GitHub Issue Tracker.
Async image decoding, 0 freezes
This library works outside the UI thread, ensuring that your app runs smoothly and avoiding ANR ("Application Not Responding") dialogs. Just call the desired decoding method, and handle the resulting image once the process is done.
Auto cache and image downsample
Android doesn't auto-scale or downsample images to save memory, nor does it cache them by default, so the Android developer must handle these tasks manually in order to avoid outOfMemoryErrors and slowed down apps.
Epic Bitmap Renderer auto handles all these annoying tasks every time you decode an image, speeding up further decodes of the same resource and decoding the image downsampled at the required viewport size, saving memory and letting you focus on the important things of your Android app development.
Using the library
Epic Bitmap Renderer exposes static methods and overridable callbacks to handle decoded image and errors once the decoding process is completed. These customizable actions make EpicBitmapRenderer a nice alternative to Picasso.
The library is available on JCenter and Maven Central, so you just have to add the dependency to use it.
Here is a bunch of useful links to learn how to use the library in your project:
//Add this on your gradle dependencies
compile 'com.isaacrf.epicbitmaprenderer:epicbitmaprenderer:1.0'
/* Sample 1: Decode Bitmap from Resource app icon, downsample
if needed to fit in 200x200 ImageView, async */
EpicBitmapRenderer.decodeBitmapFromResource(getResources(),
R.mipmap.ic_launcher,
200, 200,
new OnBitmapRendered() {
@Override
public void onBitmapRendered(Bitmap bitmap) {
//Display rendered Bitmap when successfully decoded
ImageView imageView =
(ImageView) findViewById(R.id.imgViewId);
imageView.setImageBitmap(bitmap);
}
},
new OnBitmapRenderFailed() {
@Override
public void onBitmapRenderFailed(Exception e) {
//Take actions if Bitmap fails to render
Toast.makeText(MainActivity.this,
"Failed to load Bitmap: " +
e.getMessage(),
Toast.LENGTH_SHORT).show();
}
});
Contribute
Do you like this project?
Buy me a coffeeNew rendering methods or functionalities in mind? Improve the library by forking the repository, or opening an issue on GitHub.
Fork on GitHub IssueStarring and watching the project also helps making it grow.
Star Watch