package eclipsePackage;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class ImageProcessing {
/**
* @param args
*/
public static void main(String[] args) throws IOException
{
// TODO Auto-generated method stub
// Read an image.
String img= "C:/eclipse/cat1.jpeg";
BufferedImage input = ImageIO.read(new File(img));
// Create a black-and-white image of the same size.
BufferedImage im =
new BufferedImage(input.getWidth(),input.getHeight(),BufferedImage.TYPE_BYTE_BINARY);
// Get the graphics context for the black-and-white image.
Graphics2D g2d = im.createGraphics();
// Render the input image on it.
g2d.drawImage(input,0,0,null);
// Store the resulting image using the PNG format.
ImageIO.write(im,"JPEG",new File("rendered_cat1.jpeg"));
}
答案 0 :(得分:0)
试试这个:C:\\eclipse\\cat1.jpeg