private static BufferedImage readJpeg(InputStream in) throws IOException {
        Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName("JPEG");
        ImageReader reader = null;
        while (readers.hasNext()) {
            reader = readers.next();
            if (reader.canReadRaster()) {
                break;
            }
        }
        if (reader == null)
            return null;
        try {
            ImageInputStream input = ImageIO.createImageInputStream(in);
            reader.setInput(input);
            // Read the image raster
            Raster raster = reader.readRaster(0, null);
            BufferedImage image = createJPEG4(raster);
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            writeJpeg(image, out, 1);
            out.flush();
            return read(new ByteArrayInputStream(out.toByteArray()));
        }
        finally {
            try {
                reader.dispose();
            }
            catch (Throwable e) {}
        }
    }
private static BufferedImage readJpeg(InputStream in) throws IOException {
        Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName("JPEG");
        ImageReader reader = null;
        while (readers.hasNext()) {
            reader = readers.next();
            if (reader.canReadRaster()) {
                break;
            }
        }
        if (reader == null)
            return null;
        try {
            ImageInputStream input = ImageIO.createImageInputStream(in);
            reader.setInput(input);
            
            Raster raster = reader.readRaster(0, null);
            BufferedImage image = createJPEG4(raster);
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            writeJpeg(image, out, 1);
            out.flush();
            return read(new ByteArrayInputStream(out.toByteArray()));
        }
        finally {
            try {
                reader.dispose();
            }
            catch (Throwable e) {}
        }
    }
private static BufferedImage readJpeg ( InputStream in ) throws IOException { Iterator < ImageReader > readers = ImageIO . getImageReadersByFormatName ( "JPEG" ) ; ImageReader reader = null ; while ( readers . hasNext ( ) ) { reader = readers . next ( ) ; if ( reader . canReadRaster ( ) ) { break ; } } if ( reader == null ) return null ; try { ImageInputStream input = ImageIO . createImageInputStream ( in ) ; reader . setInput ( input ) ; // Read the image raster Raster raster = reader . readRaster ( 0 , null ) ; BufferedImage image = createJPEG4 ( raster ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; writeJpeg ( image , out , 1 ) ; out . flush ( ) ; return read ( new ByteArrayInputStream ( out . toByteArray ( ) ) ) ; } finally { try { reader . dispose ( ) ; } catch ( Throwable e ) { } } }
尝试读取JPEG文件的高级方法,可读取32位的jpeg文件
<p/>
来自:
http://stackoverflow.com/questions/2408613/problem-reading-jpeg-image-
using-imageio-readfile-file
尝试读取JPEG文件的高级方法 可读取32位的jpeg文件 <p / > 来自 : http : // stackoverflow . com / questions / 2408613 / problem - reading - jpeg - image - using - imageio - readfile - file