Link to home
Start Free TrialLog in
Avatar of cemplukcute2003
cemplukcute2003

asked on

ImageReader

Hello...
I'm trying to read an image file. The format is in "pgm" files.
Because i try to make some code but it can't work. I surfed the internet and i found an article about ImageReader. I'm trying to put it in my code but it can't be compiled.
The error messages are : can't find symbol class ImageInputStream & Iterator
Can someone help me to fix this problem?
Or does someone can teach me how to read this type of files?

import java.io.*;
import java.net.*;
import java.awt.*;
import javax.imageio.*;
import javax.swing.*;

public class Source_Entropy {
      public void Source_Entropy() {
            
      }
      
      public static void main(String[] args) {
            File openFilePic;
            ImageInputStream buffInputPic;
            Iterator cekLoop = ImageIO.getImageReadersByFormatName("pgm");
            ImageReader readFile = (ImageReader)cekLoop.next();
            
            try {
                  openFilePic = new File("lena512.pgm");
                  buffInputPic = ImageIO.createImageInputStream(openFilePic);
                  
                  
            } catch(IOException e) {
                  e.printStackTrace();
      }
}
ASKER CERTIFIED SOLUTION
Avatar of matthew016
matthew016
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
import javax.imageio.stream.*;