Combine multiple bitmap into one
// 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;
}
4 Comments
Nice ...
How can we we print multiple images in pdf using Bitmap?
Nice ...
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?