Search in sources :

Example 1 with FileCacheImageOutputStream

use of javax.imageio.stream.FileCacheImageOutputStream in project jdk8u_jdk by JetBrains.

the class BitPadding method main.

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);
    }
}
Also used : OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FileCacheImageOutputStream(javax.imageio.stream.FileCacheImageOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) FileCacheImageOutputStream(javax.imageio.stream.FileCacheImageOutputStream)

Example 2 with FileCacheImageOutputStream

use of javax.imageio.stream.FileCacheImageOutputStream in project whole by wholeplatform.

the class ICNSGenerator method write.

public void write(OutputStream os) throws IOException {
    List<ICNSData> icons = new ArrayList<>();
    for (ICNSType iconType : ICNSType.values()) {
        RenderedImage image = images.get(iconType.getSize());
        if (image == null)
            throw new IllegalArgumentException("incomplete image dimesions");
        icons.add(new ICNSData(iconType, image));
    }
    try (FileCacheImageOutputStream ios = new FileCacheImageOutputStream(os, null)) {
        ios.setByteOrder(ByteOrder.BIG_ENDIAN);
        writeHeader(ios, ICNS_MAGIC, calculateTotalLength(icons));
        for (ICNSData icon : icons) writeSegments(ios, icon);
    }
}
Also used : ArrayList(java.util.ArrayList) RenderedImage(java.awt.image.RenderedImage) FileCacheImageOutputStream(javax.imageio.stream.FileCacheImageOutputStream)

Example 3 with FileCacheImageOutputStream

use of javax.imageio.stream.FileCacheImageOutputStream in project whole by wholeplatform.

the class ICOGenerator method write.

public void write(OutputStream os) throws IOException {
    List<RenderedImage> icons = new ArrayList<>();
    for (ICOType iconType : ICOType.values()) {
        RenderedImage image = images.get(iconType.getSize());
        if (image == null)
            throw new IllegalArgumentException("incomplete image dimesions");
        icons.add(iconType.isIndexed() ? PaletteBuilder.createIndexedImage(image) : image);
    }
    try (ImageOutputStream ios = new FileCacheImageOutputStream(os, null)) {
        ios.setByteOrder(ByteOrder.LITTLE_ENDIAN);
        ios.write(ICO_MAGIC);
        ios.writeShort(icons.size());
        int offset = calculateIconHeaderSize(icons.size());
        for (RenderedImage image : icons) offset = writeIconDirEntry(ios, image, offset);
        for (RenderedImage image : icons) writeIconImage(ios, image, true);
    }
}
Also used : ArrayList(java.util.ArrayList) RenderedImage(java.awt.image.RenderedImage) FileCacheImageOutputStream(javax.imageio.stream.FileCacheImageOutputStream) ImageOutputStream(javax.imageio.stream.ImageOutputStream) FileCacheImageOutputStream(javax.imageio.stream.FileCacheImageOutputStream)

Example 4 with FileCacheImageOutputStream

use of javax.imageio.stream.FileCacheImageOutputStream in project whole by wholeplatform.

the class SplashBMPGenerator method write.

public void write(OutputStream os) throws IOException {
    RenderedImage image = images.get(SPLASH_WIDTH);
    if (image == null || image.getHeight() != SPLASH_HEIGHT)
        throw new IllegalArgumentException("unsupported splash dimensions");
    else if (image.getColorModel().getPixelSize() != 32)
        throw new IllegalArgumentException("unsupported pixel size");
    try (ImageOutputStream ios = new FileCacheImageOutputStream(os, null)) {
        ios.setByteOrder(ByteOrder.LITTLE_ENDIAN);
        ios.writeShort(BMP_MAGIC);
        int imageSize = calculateBMPImageSize(image);
        ios.writeInt(BMP_HEADER_SIZE + imageSize);
        ios.writeInt(0);
        ios.writeInt(BMP_HEADER_SIZE);
        writeIconImage(ios, image, false);
    }
}
Also used : RenderedImage(java.awt.image.RenderedImage) FileCacheImageOutputStream(javax.imageio.stream.FileCacheImageOutputStream) ImageOutputStream(javax.imageio.stream.ImageOutputStream) FileCacheImageOutputStream(javax.imageio.stream.FileCacheImageOutputStream)

Example 5 with FileCacheImageOutputStream

use of javax.imageio.stream.FileCacheImageOutputStream in project jdk8u_jdk by JetBrains.

the class FlushBefore method main.

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);
}
Also used : MemoryCacheImageOutputStream(javax.imageio.stream.MemoryCacheImageOutputStream) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FileCacheImageOutputStream(javax.imageio.stream.FileCacheImageOutputStream) MemoryCacheImageOutputStream(javax.imageio.stream.MemoryCacheImageOutputStream) ImageOutputStream(javax.imageio.stream.ImageOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FileCacheImageOutputStream(javax.imageio.stream.FileCacheImageOutputStream)

Aggregations

FileCacheImageOutputStream (javax.imageio.stream.FileCacheImageOutputStream)5 RenderedImage (java.awt.image.RenderedImage)3 ImageOutputStream (javax.imageio.stream.ImageOutputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2 File (java.io.File)1 MemoryCacheImageOutputStream (javax.imageio.stream.MemoryCacheImageOutputStream)1