0
I would like to generate images with dynamic texts!
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();
}
}
I wonder how do I break the text?
It will be necessary to calculate how many characters fit, and adding each line?
Or is there some way to break automatically?
Thanks in advance!
Hello, why you need the text to be part of the image ? why not just put the text on the image ?
– Duanniston Cardoso Cabral
it will be exported! It is not a screen, but a result that will be generated for the user to export
– Thiago Luiz Domacoski