private InputStream fakeBMPHeader(final QuickTime.ImageDesc pDescription) throws IOException { int bmpHeaderSize = 14; int dibHeaderSize = 12; // 12: OS/2 V1 ByteArrayOutputStream out = new FastByteArrayOutputStream(bmpHeaderSize + dibHeaderSize); LittleEndianDataOutputStream stream = new LittleEndianDataOutputStream(out); // BMP header stream.writeByte('B'); stream.writeByte('M'); stream.writeInt(pDescription.dataSize + bmpHeaderSize + dibHeaderSize); // Data size + BMP header + DIB header stream.writeShort(0x0); // Reserved stream.writeShort(0x0); // Reserved stream.writeInt(bmpHeaderSize + dibHeaderSize); // Image offset // DIB header stream.writeInt(dibHeaderSize); // DIB header size stream.writeShort(pDescription.width); stream.writeShort(pDescription.height); stream.writeShort(1); // Planes, only legal value: 1 stream.writeShort(pDescription.depth); // Bit depth return new ByteArrayInputStream(out.toByteArray()); } }
/** * Writes a {@code boolean} to the underlying output stream as * a single byte. If the argument is true, the byte value 1 is written. * If the argument is false, the byte value {@code 0} in written. * * @param pBoolean the {@code boolean} value to be written. * @throws IOException if the underlying stream throws an IOException. */ public void writeBoolean(boolean pBoolean) throws IOException { if (pBoolean) { write(1); } else { write(0); } }
/** * Writes an 8 byte Java double to the underlying output stream in * little endian order. * * @param d the {@code double} value to be written. * @throws IOException if an I/O error occurs. */ public final void writeDouble(double d) throws IOException { writeLong(Double.doubleToLongBits(d)); }
LittleEndianDataOutputStream dataStream = new LittleEndianDataOutputStream(stream); dataStream.write(CompoundDocument.MAGIC); // 8 bytes magic dataStream.write(new byte[16]); // UUID 16 bytes, all zero dataStream.write(new byte[]{0x3E, 0, 3, 0}); // version (62), rev (3) dataStream.write(new byte[]{(byte) 0xfe, (byte) 0xff}); // Byte order dataStream.write(new byte[]{9, 0, 6, 0}); // Sector size (1 << x), short sector size dataStream.write(new byte[10]); // Reserved 10 bytes dataStream.writeInt(1); // SAT size (1) dataStream.writeInt(1); // Directory SId dataStream.write(new byte[4]); // Reserved 4 bytes dataStream.writeInt(4096); // Min stream size (4096) dataStream.writeInt(3); // Short SAT SId dataStream.writeInt(1); // Short SAT size dataStream.writeInt(-2); // Master SAT SId (-2, end of chain) dataStream.writeInt(0); // Master SAT size dataStream.writeInt(0); // Master SAT entry 0 (0) dataStream.writeInt(128); // Master SAT entry 1 (128) dataStream.write(createPad(428, (byte) -1)); // Pad (until 512 bytes) dataStream.writeInt(-3); // SAT entry 0 (SAT) dataStream.writeInt(-2); // SAT entry 1 (EOS) dataStream.write(createPad(512 - 8, (byte) -1)); // Pad (until 512 bytes)
/** * Writes a 4 byte Java float to the underlying output stream in * little endian order. * * @param f the {@code float} value to be written. * @throws IOException if an I/O error occurs. */ public final void writeFloat(float f) throws IOException { writeInt(Float.floatToIntBits(f)); }
LittleEndianDataOutputStream dataStream = new LittleEndianDataOutputStream(stream); dataStream.write(CompoundDocument.MAGIC); // 8 bytes magic dataStream.write(new byte[16]); // UUID 16 bytes, all zero dataStream.write(new byte[]{0x3E, 0, 3, 0}); // version (62), rev (3) dataStream.write(new byte[]{(byte) 0xfe, (byte) 0xff}); // Byte order dataStream.write(new byte[]{9, 0, 6, 0}); // Sector size (1 << x), short sector size dataStream.write(new byte[10]); // Reserved 10 bytes dataStream.writeInt(1); // SAT size (1) dataStream.writeInt(1); // Directory SId dataStream.write(new byte[4]); // Reserved 4 bytes dataStream.writeInt(4096); // Min stream size (4096) dataStream.writeInt(3); // Short SAT SId dataStream.writeInt(1); // Short SAT size dataStream.writeInt(-2); // Master SAT SId (-2, end of chain) dataStream.writeInt(0); // Master SAT size dataStream.writeInt(0); // Master SAT entry 0 (0) dataStream.writeInt(128); // Master SAT entry 1 (128) dataStream.write(createPad(428, (byte) -1)); // Pad (until 512 bytes) dataStream.writeInt(-3); // SAT entry 0 (SAT) dataStream.writeInt(-2); // SAT entry 1 (EOS) dataStream.write(createPad(512 - 8, (byte) -1)); // Pad (until 512 bytes)
/** * Writes a 4 byte Java float to the underlying output stream in * little endian order. * * @param f the {@code float} value to be written. * @throws IOException if an I/O error occurs. */ public final void writeFloat(float f) throws IOException { writeInt(Float.floatToIntBits(f)); }
private InputStream fakeBMPHeader(final QuickTime.ImageDesc pDescription) throws IOException { int bmpHeaderSize = 14; int dibHeaderSize = 12; // 12: OS/2 V1 ByteArrayOutputStream out = new FastByteArrayOutputStream(bmpHeaderSize + dibHeaderSize); LittleEndianDataOutputStream stream = new LittleEndianDataOutputStream(out); // BMP header stream.writeByte('B'); stream.writeByte('M'); stream.writeInt(pDescription.dataSize + bmpHeaderSize + dibHeaderSize); // Data size + BMP header + DIB header stream.writeShort(0x0); // Reserved stream.writeShort(0x0); // Reserved stream.writeInt(bmpHeaderSize + dibHeaderSize); // Image offset // DIB header stream.writeInt(dibHeaderSize); // DIB header size stream.writeShort(pDescription.width); stream.writeShort(pDescription.height); stream.writeShort(1); // Planes, only legal value: 1 stream.writeShort(pDescription.depth); // Bit depth return new ByteArrayInputStream(out.toByteArray()); } }
/** * Writes a 4 byte Java float to the underlying output stream in * little endian order. * * @param f the {@code float} value to be written. * @throws IOException if an I/O error occurs. */ public final void writeFloat(float f) throws IOException { writeInt(Float.floatToIntBits(f)); }
/** * Writes a {@code boolean} to the underlying output stream as * a single byte. If the argument is true, the byte value 1 is written. * If the argument is false, the byte value {@code 0} in written. * * @param pBoolean the {@code boolean} value to be written. * @throws IOException if the underlying stream throws an IOException. */ public void writeBoolean(boolean pBoolean) throws IOException { if (pBoolean) { write(1); } else { write(0); } }
/** * Writes an 8 byte Java double to the underlying output stream in * little endian order. * * @param d the {@code double} value to be written. * @throws IOException if an I/O error occurs. */ public final void writeDouble(double d) throws IOException { writeLong(Double.doubleToLongBits(d)); }
private InputStream fakeBMPHeader(final QuickTime.ImageDesc pDescription) throws IOException { int bmpHeaderSize = 14; int dibHeaderSize = 12; // 12: OS/2 V1 ByteArrayOutputStream out = new FastByteArrayOutputStream(bmpHeaderSize + dibHeaderSize); LittleEndianDataOutputStream stream = new LittleEndianDataOutputStream(out); // BMP header stream.writeByte('B'); stream.writeByte('M'); stream.writeInt(pDescription.dataSize + bmpHeaderSize + dibHeaderSize); // Data size + BMP header + DIB header stream.writeShort(0x0); // Reserved stream.writeShort(0x0); // Reserved stream.writeInt(bmpHeaderSize + dibHeaderSize); // Image offset // DIB header stream.writeInt(dibHeaderSize); // DIB header size stream.writeShort(pDescription.width); stream.writeShort(pDescription.height); stream.writeShort(1); // Planes, only legal value: 1 stream.writeShort(pDescription.depth); // Bit depth return new ByteArrayInputStream(out.toByteArray()); } }
/** * Writes a {@code boolean} to the underlying output stream as * a single byte. If the argument is true, the byte value 1 is written. * If the argument is false, the byte value {@code 0} in written. * * @param pBoolean the {@code boolean} value to be written. * @throws IOException if the underlying stream throws an IOException. */ public void writeBoolean(boolean pBoolean) throws IOException { if (pBoolean) { write(1); } else { write(0); } }
/** * Writes an 8 byte Java double to the underlying output stream in * little endian order. * * @param d the {@code double} value to be written. * @throws IOException if an I/O error occurs. */ public final void writeDouble(double d) throws IOException { writeLong(Double.doubleToLongBits(d)); }