能否将位于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);
}
}
android.graphics
包中。 - Ted Hopp