Java 类javax.imageio.stream.FileCacheImageOutputStream 实例源码

项目:openjdk-jdk10    文件:BitPadding.java   
public static void main(String[] args) throws IOException {
    OutputStream ostream = new ByteArrayOutputStream();
    File f = null;
    FileCacheImageOutputStream fcios =
        new FileCacheImageOutputStream(ostream, f);
    fcios.writeBit(1);
    fcios.write(96);

    fcios.seek(0);
    int r1 = fcios.read();
    if (r1 != 128 ) {
        throw new RuntimeException("Failed, first byte is " + r1);
    }

    int r2 = fcios.read();
    if (r2 != 96) {
        throw new RuntimeException("Failed, second byte is " + r2);
    }
}
项目:jdk8u_jdk    文件:BitPadding.java   
public static void main(String[] args) throws IOException {
    OutputStream ostream = new ByteArrayOutputStream();
    File f = null;
    FileCacheImageOutputStream fcios =
        new FileCacheImageOutputStream(ostream, f);
    fcios.writeBit(1);
    fcios.write(96);

    fcios.seek(0);
    int r1 = fcios.read();
    if (r1 != 128 ) {
        throw new RuntimeException("Failed, first byte is " + r1);
    }

    int r2 = fcios.read();
    if (r2 != 96) {
        throw new RuntimeException("Failed, second byte is " + r2);
    }
}
项目:sagetv-phoenix-core    文件:ImageUtil.java   
/**
 * Writes the image to an output stream
 *
 * @param img
 * @param ext
 * @param os
 */
public static void writeImageWithCompression(BufferedImage img, String ext, OutputStream os) {
    img = fixImage(img, ext);

    try {
        Iterator<ImageWriter> i = ImageIO.getImageWritersBySuffix(ext);
        ImageWriter jpegWriter = i.next();

        // Set the compression quality to 0.8
        ImageWriteParam param = jpegWriter.getDefaultWriteParam();
        param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
        param.setCompressionQuality(getDefaultImageCompression());

        // Write the image to a file
        FileCacheImageOutputStream out = new FileCacheImageOutputStream(os, getTempImageCacheDir());
        jpegWriter.setOutput(out);
        jpegWriter.write(null, new IIOImage(img, null, null), param);
        jpegWriter.dispose();
        out.flush();
        out.close();
    } catch (IOException e) {
        log.error("Failed to save image to stream", e);
    }
}
项目:imagine    文件:Resizer.java   
public void writeImage(
        final BufferedImage sourceImage,
        final OutputStream outputStream,
        final File cacheDir) throws IOException {

    try (
        final CloseableImageWriter writer = new CloseableImageWriter("jpg");
        // TODO: should this be in-memory?
        final ImageOutputStream imageOutputStream = new FileCacheImageOutputStream(outputStream, cacheDir)
    ) {
        writer.setOutput(imageOutputStream);
        final BufferedImage resizedImage = this.resizeImage(sourceImage);
        final IIOImage outputImage = new IIOImage(resizedImage, null, null);
        final ImageWriteParam param = writer.getDefaultWriteParam();
        param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
        param.setCompressionQuality(this.quality);
        writer.write(outputImage, param);
    }
}
项目:lams    文件:BufferedImageHttpMessageConverter.java   
private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
    if (this.cacheDir != null) {
        return new FileCacheImageOutputStream(os, this.cacheDir);
    }
    else {
        return new MemoryCacheImageOutputStream(os);
    }
}
项目:OpenJSharp    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:jdk8u-jdk    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:openjdk-jdk10    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:openjdk-jdk10    文件:FlushBefore.java   
public static void main(String[] args) throws IOException {
    OutputStream ostream = new ByteArrayOutputStream();

    FileCacheImageOutputStream fcios =
        new FileCacheImageOutputStream(ostream, null);
    test(fcios);

    MemoryCacheImageOutputStream mcios =
        new MemoryCacheImageOutputStream(ostream);
    test(mcios);
}
项目:openjdk9    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:spring4-understanding    文件:BufferedImageHttpMessageConverter.java   
private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
    if (this.cacheDir != null) {
        return new FileCacheImageOutputStream(os, this.cacheDir);
    }
    else {
        return new MemoryCacheImageOutputStream(os);
    }
}
项目:jdk8u_jdk    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:jdk8u_jdk    文件:FlushBefore.java   
public static void main(String[] args) throws IOException {
    OutputStream ostream = new ByteArrayOutputStream();

    FileCacheImageOutputStream fcios =
        new FileCacheImageOutputStream(ostream, null);
    test(fcios);

    MemoryCacheImageOutputStream mcios =
        new MemoryCacheImageOutputStream(ostream);
    test(mcios);
}
项目:lookaside_java-1.8.0-openjdk    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:infobip-open-jdk-8    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:jdk8u-dev-jdk    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:jdk7-jdk    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:openjdk-source-code-learn    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:class-guard    文件:BufferedImageHttpMessageConverter.java   
private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
    if (this.cacheDir != null) {
        return new FileCacheImageOutputStream(os, this.cacheDir);
    }
    else {
        return new MemoryCacheImageOutputStream(os);
    }
}
项目:OLD-OpenJDK8    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:cn1    文件:OutputStreamIOSSpi.java   
@Override
public ImageOutputStream createOutputStreamInstance(Object output, boolean useCache, File cacheDir) throws IOException {
    if (output instanceof OutputStream) {
        if (useCache) {
            return new FileCacheImageOutputStream((OutputStream) output, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream((OutputStream) output);
        }
    }
    throw new IllegalArgumentException(Messages.getString("imageio.85"));
}
项目:openjdk-jdk7u-jdk    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:freeVM    文件:OutputStreamIOSSpi.java   
@Override
public ImageOutputStream createOutputStreamInstance(Object output, boolean useCache, File cacheDir) throws IOException {
    if (output instanceof OutputStream) {
        if (useCache) {
            return new FileCacheImageOutputStream((OutputStream) output, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream((OutputStream) output);
        }
    }
    throw new IllegalArgumentException("Output is not an instance of OutputStream");
}
项目:freeVM    文件:OutputStreamIOSSpi.java   
@Override
public ImageOutputStream createOutputStreamInstance(Object output, boolean useCache, File cacheDir) throws IOException {
    if (output instanceof OutputStream) {
        if (useCache) {
            return new FileCacheImageOutputStream((OutputStream) output, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream((OutputStream) output);
        }
    }
    throw new IllegalArgumentException(Messages.getString("imageio.85"));
}
项目:openjdk-icedtea7    文件:OutputStreamImageOutputStreamSpi.java   
public ImageOutputStream createOutputStreamInstance(Object output,
                                                    boolean useCache,
                                                    File cacheDir)
    throws IOException {
    if (output instanceof OutputStream) {
        OutputStream os = (OutputStream)output;
        if (useCache) {
            return new FileCacheImageOutputStream(os, cacheDir);
        } else {
            return new MemoryCacheImageOutputStream(os);
        }
    } else {
        throw new IllegalArgumentException();
    }
}