我想以编程方式制作这样的图像:

我有上面的图像和文字.我应该在图像上写文字吗?
我想让它成为一个完整的.png图像(图像+标签)并将其设置为按钮的背景.
是否可以将EditText框内的字符串文本转换为位图?换句话说,有没有办法将字符串文本转换为位图,这意味着文本将显示为图像?
以下是我的代码:
class TextToImage extends Activity {
protected void onCreate(Bundle savedInstanceState) {
//create String object to be converted to image
String sampleText = "SAMPLE TEXT";
String fileName = "Image";
//create a File Object
File newFile = new File("./" + fileName + ".jpeg");
//create the font you wish to use
Font font = new Font("Tahoma", Font.PLAIN, 11);
//create the FontRenderContext object which helps us to measure the text
FontRenderContext frc = new FontRenderContext(null, true, true);
}
}
Run Code Online (Sandbox Code Playgroud) 我的图像位于我的java项目中的images/image.png.我想写一个方法,其签名如下
byte[] mergeImageAndText(String imageFilePath, String text, Point textPosition);
此方法将加载位于图像imageFilePath和在位置textPosition欲写入的图像(左上)的text,那么我想返回表示与文本新的图像合并一个字节[].