Combine multiple bitmap into one

1 vote · 4 comments

Combine multiple bitmap into one

raw ·
copy
· download
// Example: // Bitmap bm1=BitmapFactory.decodeResource(getResources(),.drawable.ic_launcher); // ArrayList<Bitmap> a=new ArrayList<Bitmap>(); // a.add(bm1); // a.add(bm1); // a.add(bm1); // combineImageIntoOne(a); // Cobine Multi Image Into One private Bitmap combineImageIntoOne(ArrayList<Bitmap> bitmap) { int w = 0, h = 0; for (int i = 0; i < bitmap.size(); i++) { if (i < bitmap.size() - 1) { w = bitmap.get(i).getWidth() > bitmap.get(i + 1).getWidth() ? bitmap.get(i).getWidth() : bitmap.get(i + 1).getWidth(); } h += bitmap.get(i).getHeight(); } Bitmap temp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(temp); int top = 0; for (int i = 0; i < bitmap.size(); i++) { Log.d("HTML", "Combine: "+i+"/"+bitmap.size()+1); top = (i == 0 ? 0 : top+bitmap.get(i).getHeight()); canvas.drawBitmap(bitmap.get(i), 0f, top, null); } return temp; }
Add a comment

4 Comments

Nice ...

Reply · Nov. 12, 2014, 9:59 a.m.

How can we we print multiple images in pdf using Bitmap?

Reply · Nov. 12, 2014, 10:02 a.m.

Nice ...

Reply · Nov. 12, 2014, 9:59 a.m.

where i can see the combine image? Everything is fine and seen i Logcat but i dont know where i can see the actual images?

Reply · Dec. 11, 2014, 8:59 a.m.