/*
* Program for drawing string or text over a image and save with that
* Copyright 2009 @ yuvadeveloper
* Code By:- Prashant Chandrakar
*
*/
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
class DrawString
{
public static void main(String a[])
{
try
{
////pass image file path open for drawing
BufferedImage image = ImageIO.read(new File("test.JPEG"));
////taking graphics from image
Graphics g = image.getGraphics();
/////drawing string on graphics of opened image
g.drawString("I am a string drawn on image pixel", 10, image.getHeight() - 10);
////saving image by name output.jpg
ImageIO.write(image, "jpg", new File("output.jpg"));
}
catch (Exception e)
{
System.out.println(e);
}
}
}
No comments:
Post a Comment