I would like to generate images with dynamic text!
public void generate()
{
Bitmap src = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
Bitmap dest = Bitmap.createBitmap(500, 800, Bitmap.Config.ARGB_8888);
String yourText = "Este é meu texto personalizado que vou adicionar em uma imagem de teste qwerty yrrwwq";
Canvas cs = new Canvas(dest);
Paint tPaint = new Paint();
tPaint.setTextSize(35);
tPaint.setColor(Color.BLUE);
tPaint.setStyle(Paint.Style.FILL);
cs.drawColor(Color.WHITE);
cs.drawBitmap(src, 0f, 0f, null);
cs.drawText(yourText, 10, 50, tPaint);
try {
dest.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File("/sdcard/ImageAfterAddingText.jpg")));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
Would you like to know how to break the text?
Will it be necessary to calculate how many characters fit, and adding each line?
Or is there any way to break automatically?
Thank you in advance!