As the title suggest, I am trying to read and output a raw image file. My goal in this program is to read a raw image and do some image processing and then output the final image. I got an idea how to do this program but I am stuck trying to read a raw image in java. Im not even sure how to upload the raw image into my project folder properly. Any advice will be appreciated. Here is my code so far (granted I took this code from a website to test out).
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Assignment_1 {
void importImageIGuess() {
}
public static void main(String[] args) throws IOException {
int width = 512;
int length = 512;
BufferedImage image = null;
File f = null;
//Read File I guess
try {
f = new File("lena.raw");
image = new BufferedImage(width, length, BufferedImage.TYPE_INT_ARGB);
image = ImageIO.read(f);
System.out.println("Reading completed");
}
catch(IOException e) {
System.out.println("Error " +e);
}
try{
f = new File("lenaOutput.raw");
ImageIO.write(image, "raw", f);
System.out.println("Writing completed I guess");
} catch (IOException e ) {
System.out.println("Error " + e);
}
}
}