Add text to an image in Java
2013-10-14 09:08
465 查看
http://stackoverflow.com/questions/10929524/how-to-add-text-to-an-image-in-java
import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.net.URL; import javax.imageio.ImageIO; public class Graph { public static void main(String[] args) throws Exception { final BufferedImage image = ImageIO.read(new URL( "http://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png")); Graphics g = image.getGraphics(); g.setFont(g.getFont().deriveFont(30f)); g.drawString("Hello World!", 100, 100); g.dispose(); ImageIO.write(image, "png", new File("test.png")); } }
相关文章推荐
- Using Imagecache and CCK Imagefield to Add an Image in Drupal
- Add Alt Text to an Image for Accessibility训练25
- 错误 the type "xxxx" is defined in an assembly that is not refernced.You must add a reference to assem
- Units Problem: How to read text size as custom attr from xml and set it to TextView in java code
- How to store an image file to SQliteDB in android
- Uploading an image to a webserver – Android/Java
- Add mappings to an Elasticsearch index in realtime
- How to: Add an Action Method to an MVC Controller in Visual Studio
- How to add or list certificates from keystore or trustStore in Java - Keytool Example Read more: ht
- java 更换皮肤问题Cannot refer to a non-final variable inside an inner class defined in a different method
- Convert image to text in .net
- win7 64下VC++6.0(Unable to register this add-in because its DLLRegisterServer return an error)
- Is there a way to add a badge to an application icon in Android?
- In Java, how do I read/convert an InputStream to a String? - Stack Overflow
- VC++ Unable to register this add-in because its DllRegisterServer returns an error 解决方案
- Units Problem: How to read text size as custom attr from xml and set it to TextView in java code
- java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method 解决办法
- Annotations in Tiger, Part 1: Add metadata to Java code
- How to Add An Automatically Executable Program in YOCTO?
- WIN7下VC6.0无法使用打开文件功能(Unable to register this add-in because its DLLRegisterServer return an error)