java类javax.imageio.stream.FileCacheImageOutputStream的实例源码

BitPadding.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
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);
    }
}
BitPadding.java 文件源码 项目:jdk8u_jdk 阅读 26 收藏 0 点赞 0 评论 0
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);
    }
}
ImageUtil.java 文件源码 项目:sagetv-phoenix-core 阅读 50 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
Resizer.java 文件源码 项目:imagine 阅读 22 收藏 0 点赞 0 评论 0
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);
    }
}
BufferedImageHttpMessageConverter.java 文件源码 项目:lams 阅读 23 收藏 0 点赞 0 评论 0
private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
    if (this.cacheDir != null) {
        return new FileCacheImageOutputStream(os, this.cacheDir);
    }
    else {
        return new MemoryCacheImageOutputStream(os);
    }
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:OpenJSharp 阅读 31 收藏 0 点赞 0 评论 0
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();
    }
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:jdk8u-jdk 阅读 25 收藏 0 点赞 0 评论 0
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();
    }
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:openjdk-jdk10 阅读 33 收藏 0 点赞 0 评论 0
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();
    }
}
FlushBefore.java 文件源码 项目:openjdk-jdk10 阅读 34 收藏 0 点赞 0 评论 0
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);
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:openjdk9 阅读 24 收藏 0 点赞 0 评论 0
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();
    }
}
BufferedImageHttpMessageConverter.java 文件源码 项目:spring4-understanding 阅读 24 收藏 0 点赞 0 评论 0
private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
    if (this.cacheDir != null) {
        return new FileCacheImageOutputStream(os, this.cacheDir);
    }
    else {
        return new MemoryCacheImageOutputStream(os);
    }
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:jdk8u_jdk 阅读 32 收藏 0 点赞 0 评论 0
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();
    }
}
FlushBefore.java 文件源码 项目:jdk8u_jdk 阅读 30 收藏 0 点赞 0 评论 0
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);
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 24 收藏 0 点赞 0 评论 0
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();
    }
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:infobip-open-jdk-8 阅读 32 收藏 0 点赞 0 评论 0
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();
    }
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:jdk8u-dev-jdk 阅读 29 收藏 0 点赞 0 评论 0
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();
    }
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:jdk7-jdk 阅读 26 收藏 0 点赞 0 评论 0
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();
    }
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:openjdk-source-code-learn 阅读 27 收藏 0 点赞 0 评论 0
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();
    }
}
BufferedImageHttpMessageConverter.java 文件源码 项目:class-guard 阅读 23 收藏 0 点赞 0 评论 0
private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
    if (this.cacheDir != null) {
        return new FileCacheImageOutputStream(os, this.cacheDir);
    }
    else {
        return new MemoryCacheImageOutputStream(os);
    }
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:OLD-OpenJDK8 阅读 27 收藏 0 点赞 0 评论 0
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();
    }
}
OutputStreamIOSSpi.java 文件源码 项目:cn1 阅读 24 收藏 0 点赞 0 评论 0
@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"));
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:openjdk-jdk7u-jdk 阅读 29 收藏 0 点赞 0 评论 0
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();
    }
}
OutputStreamIOSSpi.java 文件源码 项目:freeVM 阅读 34 收藏 0 点赞 0 评论 0
@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");
}
OutputStreamIOSSpi.java 文件源码 项目:freeVM 阅读 22 收藏 0 点赞 0 评论 0
@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"));
}
OutputStreamImageOutputStreamSpi.java 文件源码 项目:openjdk-icedtea7 阅读 25 收藏 0 点赞 0 评论 0
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();
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号