I’m working on a piece of code where i have to write text and images on a bitmap. Unfortunately i don’t know the number of text items to be added in bitmap. To begin i create a bitmap by this
Bitmap bitMapBuffer = Bitmap.createBitmap(containerWidth,50, Bitmap.Config.ARGB_8888);
the problem is .. the above bitmap is fixed size.. so after a while whatever i write does not show up on bitmap. How can i make it work, i mean a kind of stretched bitmap type. I looked in BitmapDrawable, but i cannot pass a drawable to a canvas like this
Canvas c1 = new Canvas(bitMapBuffer);
How can i handle this scenario?
You need to keep track of how big a bitmap you need. When you need to add another piece of text and this would take you over the limit of the current bitmap, you need to create a new one. Here’s pseudocode for one way to do this:
In this code,
deltais the added height you want to for the bitmap.