posted 16 years ago
Hi Thanks for your reply,
I am able to create JPG file but its not displaying text in the image.
public static void main(String[] args)
{
int width = 200;
int height = 100;
// Create a buffered image in which to draw
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// Create a graphics contents on the buffered image
Graphics2D g2d = bufferedImage.createGraphics();
// Draw graphics
g2d.setColor(Color.white);
g2d.fillRect(0, 0, width, height);
g2d.setColor(Color.black);
g2d.drawString("Sample-Text", 0, 0);
RenderedImage rendImage = bufferedImage;
try {
// Save as JPEG
File file = new File("newimage.jpg");
ImageIO.write(rendImage, "jpg", file);
} catch (IOException e) {
}
// Graphics context no longer needed so dispose it
g2d.dispose();
// return bufferedImage;
}