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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations