Hi! How can we put some text in an image file using Java? I have a String and I want to put this String in an image file (.gif, .bmp, .jpg or any other). Any help would be appreciated.
Thank you. Ishan
Peter Chase
Ranch Hand
Joined: Oct 30, 2001
Posts: 1970
posted
0
You certainly can write text into an image in Java, and you can write the result into a file in some popular image formats.
However, if, as posting in the beginner forum suggests, you are new to Java, this might not be a good choice for your first Java program!
To write text into the image, you need to get it as a BufferedImage. Then get a Graphics2D from your BufferedImage. Then you can use Graphics2D.drawString() to write text. You may wish to set the Font and Color of the Graphics2D before writing the text. A FontMetrics object can be used to find out how big the text will be.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P