image

by Vinoth 2009-04-22 08:26:17

Follow the below to change image to bufferedimage

import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.ImageIO;
import java.util.*;
import java.sql.*;
import java.awt.Graphics2D;

public class IMG{
private static final int DEFAULT_IMAGE_TYPE = BufferedImage.TYPE_INT_RGB;
public static void main(String arg[]){
try{ File file = new File("hiox.gif");
Image image = ImageIO.read(file);
BufferedImage cpimg=bufferImage(image,BufferedImage.TYPE_INT_RGB);
Graphics g = cpimg.createGraphics();
//g.setColor(background);
//g.fillRect(0,0,width,height);
Font fnt=new Font("Impact",1,14);
Color fntC = new Color(0,100,0);
g.setColor(fntC);
g.setFont(fnt);
g.drawString("www.100pulse.com",53,15);
File f1 = new File("img"+ ".gif");
ImageIO.write(cpimg, "gif", f1);
}
catch(Exception e){

}
}
public static BufferedImage bufferImage(Image image, int type) {
BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
Graphics2D g = bufferedImage.createGraphics();
g.drawImage(image, null, null);
//waitForImage(bufferedImage);
return bufferedImage;
}
}



hiiox.gif




img.gif


Tagged in:

6863
like
1
dislike
0
mail
flag

You must LOGIN to add comments