I just started reading the O'Reilly book Java2D Graphics. The very first example is written using the proprietary com.sun classes, which are restricted, of course (I get the error "not accessible due to restriction on required library rt.jar").
What library should I get to use in place of com.sun.image.codec.jpeg
?
The first example in the book has the imports
import com.sun.image.codec.jpeg.ImageFormatException;
import com.sun.image.codec.jpeg.JPEGCodec;
import java.awt.image.codec.JPEGImageDecoder;
and uses them like this:
// Get the specified image.
InputStream in = getClass().getResourceAsStream(filename);
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in);
mImage = decoder.decodeAsBufferedImage();
in.close();
How about this one?
import javax.imageio.ImageIO;
BufferedImage image = ImageIO.read(file);