Overlay two bitmaps in android

In last post I explained how to reduce the size of bitmap. In this post I will explain how we can overlay two bitmaps.

The use case of this program is to fix resolution of the bitmap without changing the aspect ratio.

The above function takes two bitmaps and returns a single bitmap. This is very useful when we want to add a background colour or image on an existing bitmap.

How to resize bitmap

In this section I will show how to resize bitmap keeping the aspect ratio intact. Without changing the aspect ration bitmap can be manipulated and resized to any desired resolution.

 

createScaledBitmap: Creates a new bitmap, scaled from an existing bitmap, when possible. If the specified width and height are the same as the current width and height of the source bitmap, the source bitmap is returned and no new bitmap is created.

Leave a Reply