Added all remaining gists.
This commit is contained in:
1
combineBMP.java/README.md
Normal file
1
combineBMP.java/README.md
Normal file
@@ -0,0 +1 @@
|
||||
Combine two Android Bitmaps side by side.
|
23
combineBMP.java/combineBMP.java
Normal file
23
combineBMP.java/combineBMP.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* <p>This method combines two images into one by rendering them side by side.</p>
|
||||
*
|
||||
* @param left The image that goes on the left side of the combined image.
|
||||
* @param right The image that goes on the right side of the combined image.
|
||||
* @return The combined image.
|
||||
*/
|
||||
private Bitmap combineBitmaps(final Bitmap left, final Bitmap right){
|
||||
// Get the size of the images combined side by side.
|
||||
int width = left.getWidth() + right.getWidth();
|
||||
int height = left.getHeight() > right.getHeight() ? left.getHeight() : right.getHeight();
|
||||
|
||||
// Create a Bitmap large enough to hold both input images and a canvas to draw to this
|
||||
// combined bitmap.
|
||||
Bitmap combined = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(combined);
|
||||
|
||||
// Render both input images into the combined bitmap and return it.
|
||||
canvas.drawBitmap(left, 0f, 0f, null);
|
||||
canvas.drawBitmap(right, left.getWidth(), 0f, null);
|
||||
|
||||
return combined;
|
||||
}
|
Reference in New Issue
Block a user