如何在Java中的图像上书写文字(安卓)图像、文字、如何在、Java

2023-09-04 23:50:21 作者:感谢经历

我可以在iPhone上的Objective-C的做到这一点,但现在我正在寻找同等的Andr​​oid的Java code。我也可以做到这一点在普通的Java,但我不知道什么是Android的具体类。我想产生的,有一些文字为中心的形象飞PNG图像。

I can do this in Objective-C on the iPhone, but now I'm looking for the equivalent Android Java code. I can also do it in plain Java, but I don't know what the Android specific classes are. I want to generate a PNG image on the fly that has some text centered in the image.

公共无效的createImage(串词,串outputFilePath){/ *我该怎么办吗? * /}

public void createImage(String word, String outputFilePath){ /* what do I do here? */ }

相关主题:

How写图​​像在Objective-C iPhone文本?

How我可以加载图像和使用Java写的文字呢?

推荐答案

什么是这样的:

Bitmap bitmap = ... // Load your bitmap here
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(); 
paint.setColor(Color.BLACK); 
paint.setTextSize(10); 
canvas.drawText("Some Text here", x, y, paint);
 
精彩推荐
图片推荐