This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Is there a good source code example that demonstrates how to embed text into an exisiting JPEG image. I want to put some copyright information into several hundred JPEG files, but can't find a good reference. I bought the Java2D API reference, but although it's excellent, this text doesn't appear to have a lot of simple examples to get you understanding the basic stuff first. I look forward to anyone's reply. Thanks. -- Mike
The Java2D API contains a factory for creating some kind of JPEG decoder and encoder objects. 1) Get an implementation of the JPEGImageDecoder interface with JPEGCodec.createJPEGDecoder(InputStream) 2) Call decodeAsBufferedImage() to get a java.awt.BufferedImage of the image. 3) Use the BufferedImage's getGraphics() or createGraphics() method to get a Graphics object to draw with. 4) Draw the text with the methods provided by the Graphics class, i.e. drawString(String, int, int) or drawString(String, float, float).