当前位置: 首页>>代码示例>>Java>>正文


Java FileCacheImageOutputStream类代码示例

本文整理汇总了Java中javax.imageio.stream.FileCacheImageOutputStream的典型用法代码示例。如果您正苦于以下问题:Java FileCacheImageOutputStream类的具体用法?Java FileCacheImageOutputStream怎么用?Java FileCacheImageOutputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileCacheImageOutputStream类属于javax.imageio.stream包,在下文中一共展示了FileCacheImageOutputStream类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import javax.imageio.stream.FileCacheImageOutputStream; //导入依赖的package包/类
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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:BitPadding.java

示例2: writeImageWithCompression

import javax.imageio.stream.FileCacheImageOutputStream; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:31,代码来源:ImageUtil.java

示例3: writeImage

import javax.imageio.stream.FileCacheImageOutputStream; //导入依赖的package包/类
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);
    }
}
 
开发者ID:metric-collective,项目名称:imagine,代码行数:20,代码来源:Resizer.java

示例4: createImageOutputStream

import javax.imageio.stream.FileCacheImageOutputStream; //导入依赖的package包/类
private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
	if (this.cacheDir != null) {
		return new FileCacheImageOutputStream(os, this.cacheDir);
	}
	else {
		return new MemoryCacheImageOutputStream(os);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:BufferedImageHttpMessageConverter.java

示例5: createOutputStreamInstance

import javax.imageio.stream.FileCacheImageOutputStream; //导入依赖的package包/类
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();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:OutputStreamImageOutputStreamSpi.java

示例6: main

import javax.imageio.stream.FileCacheImageOutputStream; //导入依赖的package包/类
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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:FlushBefore.java

示例7: createOutputStreamInstance

import javax.imageio.stream.FileCacheImageOutputStream; //导入依赖的package包/类
@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"));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:OutputStreamIOSSpi.java

示例8: createOutputStreamInstance

import javax.imageio.stream.FileCacheImageOutputStream; //导入依赖的package包/类
@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");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:12,代码来源:OutputStreamIOSSpi.java


注:本文中的javax.imageio.stream.FileCacheImageOutputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。