Added all remaining gists.

This commit is contained in:
Miguel Astor
2023-06-21 21:40:51 -04:00
parent 22ff5bfa25
commit b0ca706a25
26 changed files with 892 additions and 0 deletions

View File

@@ -0,0 +1 @@
Combine two Android Bitmaps side by side.

View 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;
}