Skip to content

Latest commit

 

History

History
102 lines (79 loc) · 4.16 KB

README.md

File metadata and controls

102 lines (79 loc) · 4.16 KB

Android Arsenal Travis CI

BitmapMerger

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

Merging at angle away Merging at center Merging with offsets
merge_angle_small merge_at_center_small merge_offset_small
Moon moving around the earth for various angles Stamp at center of the document being scaled Balloon flying in a beach with various offset values

###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();

Developed By