Posts

Showing posts from August, 2016

How to combine two Bitmap in Android

This blog is about how to combine 2 images in Android programatically. Note: -For this blog I am creating Bitmap instance from drawables. You can get from Camera/web APIs etc.  1. Create 2 Bitmap instance from Drawable. 1 2 3 4 5 Bitmap image1 = BitmapFactory . decodeResource ( getResources (), R . drawable . image_one ); Bitmap image2 = BitmapFactory . decodeResource ( getResources (), R . drawable . image_two ); 2. Create methods combineBitmap with 2 arguments with type of Bitmap and return type is also Bitmap. 1 public Bitmap combineImages ( Bitmap bitmap1 , Bitmap bitmap2 ){} 3. Create new instance of bitmap with bitmap2. 1 Bitmap bit1 = Bitmap . createBitmap ( bitmap2 , 0 , 0 , bitmap2 . getWidth (), bitmap2 . getHeight (), null , true ); 4. Create new Instance of Bitmap with bitmap1 which height is equals to height of bitmap1 and bitmap2. 1 Bitmap cs = Bitmap . createBitmap (