Bitmap/Read a PPM file: Difference between revisions

Content added Content deleted
(New post)
Line 1,827: Line 1,827:


public static void main(String[] aArgs) throws IOException {
public static void main(String[] aArgs) throws IOException {
// Using the file created in the Bitmap task
String filePath = "C:/Users/psnow/Desktop/output.ppm";
String filePath = "output.ppm";
reader = new BufferedInputStream( new FileInputStream(filePath) );
reader = new BufferedInputStream( new FileInputStream(filePath) );
Line 1,872: Line 1,873:
// Convert to gray scale and save to a file
// Convert to gray scale and save to a file
bitmap.convertToGrayscale();
bitmap.convertToGrayscale();
File grayFile = new File("C:/Users/psnow/Desktop/outputGray.jpg");
File grayFile = new File("outputGray.jpg");
ImageIO.write((RenderedImage) bitmap.getImage(), "jpg", grayFile);
ImageIO.write((RenderedImage) bitmap.getImage(), "jpg", grayFile);
}
}