Bitmap Merger is a simple project help you to merge two bitmaps without memory exceptions. The bitmaps are processed in background threads thereby taking the load away from UI thread. Along with merge, it also contains the image decoder for decoding images from resources/disk and are sampled to prevent OutOfMemoryError.
Examples of Bitmap Merger with this project
###Usage :
####Merging at angle away
int angle = 90; // your angle here
float scale = 0.5f; // scaling option for merging the image
Bitmap baseBitmap; // your base bitmap here
Bitmap mergeBitmap; // your merging bitmap here
ImageView imgView; // your image view for displaying the merged bitmaps.
BitmapMergerTask task = new BitmapMergerTask();
task.setBaseBitmap(baseBitmap)
.setMergeBitmap(mergeBitmap)
.setMergeListener(new BitmapMergerTask.OnMergeListener() {
@Override
public void onMerge(BitmapMergerTask task, Bitmap mergedBitmap) {
if(imgView != null) {
imgView.setImageBitmap(mergedBitmap);
}
}
})
.setScale(scale)
.setAngle(angle)
.merge();
####Merging at center
float scale = 0.5f; // scaling option for merging the image
Bitmap baseBitmap; // your base bitmap here
Bitmap mergeBitmap; // your merging bitmap here
ImageView imgView; // your image view for displaying the merged bitmaps.
BitmapMergerTask task = new BitmapMergerTask();
task.setBaseBitmap(baseBitmap)
.setMergeBitmap(mergeBitmap)
.setMergeListener(new BitmapMergerTask.OnMergeListener() {
@Override
public void onMerge(BitmapMergerTask task, Bitmap mergedBitmap) {
if(imgView != null) {
imgView.setImageBitmap(mergedBitmap);
}
}
})
.setScale(scale)
.merge();
####Merging with offsets from top left
int leftOffset = 0; // your left offset in pixels
int topOffset = 0; // your top offset in pixels
float scale = 0.5f; // scaling option for merging the image
Bitmap baseBitmap; // your base bitmap here
Bitmap mergeBitmap; // your merging bitmap here
ImageView imgView; // your image view for displaying the merged bitmaps.
BitmapMergerTask task = new BitmapMergerTask();
task.setBaseBitmap(baseBitmap)
.setMergeBitmap(mergeBitmap)
.setMergeListener(new BitmapMergerTask.OnMergeListener() {
@Override
public void onMerge(BitmapMergerTask task, Bitmap mergedBitmap) {
if(imgView != null) {
imgView.setImageBitmap(mergedBitmap);
}
}
})
.setScale(scale)
.setOffsets(leftOffset,topOffset)
.merge();
- Harish Sridharan - harish.sridhar@gmail.com