Java源码示例:com.sun.imageio.plugins.jpeg.JPEGImageReader
示例1
/** Reads the image header.
* Does nothing if the header has already been loaded.
*/
private void readHeader() throws IOException {
if (image == null) {
ImageReader r = new JPEGImageReader(getOriginatingProvider());
Object in = getInput();
/*if (in instanceof Buffer) {
Buffer buffer = (Buffer) in;
in=buffer.getData();
}*/
if (in instanceof byte[]) {
r.setInput(new MemoryCacheImageInputStream(AVIBMPDIB.prependDHTSeg((byte[]) in)));
} else if (in instanceof ImageInputStream) {
r.setInput(AVIBMPDIB.prependDHTSeg((ImageInputStream) in));
} else {
r.setInput(AVIBMPDIB.prependDHTSeg((InputStream) in));
}
image = r.read(0);
}
}
示例2
private static ImageReader createNativeJPEGReader() {
return new JPEGImageReader(new CMYKJPEGImageReaderSpi());
/*
for (Iterator<ImageReader> i =
ImageIO.getImageReadersByFormatName("jpeg"); i.hasNext();) {
ImageReader r = i.next();
if (!(r instanceof CMYKJPEGImageReader)
&& !r.getClass().getName().contains("CMYKJPEGImageReader")) {
return r;
}
}
return null;
*
*/
}
示例3
public static void main(String[] args) throws IOException {
ImageReader gifReader = new GIFImageReader(null);
ImageReader jpegReader = new JPEGImageReader(null);
ImageReader pngReader = new PNGImageReader(null);
test(gifReader, "GIF");
test(jpegReader, "JPEG");
test(pngReader, "PNG");
}
示例4
public static void main(String[] args) throws IOException {
ImageReader gifReader = new GIFImageReader(null);
ImageReader jpegReader = new JPEGImageReader(null);
ImageReader pngReader = new PNGImageReader(null);
test(gifReader, "GIF");
test(jpegReader, "JPEG");
test(pngReader, "PNG");
}