public class Test {
public static void textToImage4() throws IOException {
int width = 200, height = 135;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(Color.pink);
g.fillRect(0, 0, width, height);
// Font font = new Font("SERIF", Font.BOLD, 18);
// g2.setFont(font);
g.setColor(Color.black);
g.drawString("test", 46 , 54);
g.dispose();
ImageIO.write(image, "jpg", new File("test.jpg"));
}
public static void main(String[] args) {
Test t = new Test();
try {
t.textToImage4();
} catch (IOException ioE) {
ioE.printStackTrace();
}
}
}