In general, image manipulation is performed on the BufferedImage object. So it is useful to convert from image object to buffered image object. In Java, when you have an image object, there are two ways to convert it to the buffered image object.
One way is using the read(File file) method of the ImageIO class. See the example code below:
public void ImageToBufferedImage(String filename){
try{
BufferedImage bi=ImageIO.read(new File(filename));
//do something with the buffered image bi
}catch(IOException ie){}
}
Alternatively, you can create a blank buffered image object then draw the image on this buffered image object. See the example code below:
public void createImage(String imgfile){
BufferedImage bi=new BufferedImage(500,300, BufferedImage.TYPE_INT_ARGB);
Image img=Toolkit.getDefaultToolkit().getImage("d:/earth.png");
MediaTracker mt=new MediaTracker(this);
mt.addImage(img, 0);
try{
mt.waitForID(0);
}catch(InterruptedException e){}
Graphics2D g2d=bi.createGraphics();
g2d.drawImage(img,0,0,null);
//do something with the buffered image bi
}
The majority rule government in the United States is so unique in relation to the next nation. It appears that president runs the entire nation however it isn't genuine the foundation run the entire nation and get bestessays discounts from us. In this kind of the vote based system, you will never comprehend about the foundation.
ReplyDeleteYou're my end and my beginning
ReplyDeleteEven when I lose I'm winning
shop outfits from of your favorite TV Available now
ReplyDeleteFor the record, it is NOT the compiler that is saying that. You are actually seeing a runtime error
ReplyDeleteYour feedback helps me a lot, A very meaningful event, I hope everything will go well
ReplyDeletefreelance web developers uae exprets launched affordable website design services packages in dubai.
ReplyDelete