/** Write a little-endian 32-bit integer. */ public void writeFixed32(int value) throws IOException { sink.writeIntLe(value); }
sink.writeIntLe(bmpHeaderSize + dibHeaderSize + pixelDataSize); // File size. sink.writeShortLe(0); // Unused. sink.writeShortLe(0); // Unused. sink.writeIntLe(bmpHeaderSize + dibHeaderSize); // Offset of pixel data. sink.writeIntLe(dibHeaderSize); sink.writeIntLe(width); sink.writeIntLe(height); sink.writeShortLe(1); // Color plane count. sink.writeShortLe(bytesPerPixel * Byte.SIZE); sink.writeIntLe(0); // No compression. sink.writeIntLe(16); // Size of bitmap data including padding. sink.writeIntLe(2835); // Horizontal print resolution in pixels/meter. (72 dpi). sink.writeIntLe(2835); // Vertical print resolution in pixels/meter. (72 dpi). sink.writeIntLe(0); // Palette color count. sink.writeIntLe(0); // 0 important colors.
@Test public void writeIntLe() throws Exception { sink.writeIntLe(0xabcdef01); sink.writeIntLe(0x87654321); sink.flush(); assertEquals("[hex=01efcdab21436587]", data.toString()); }
@Test public void readIntLeTooShortThrows() throws IOException { sink.writeIntLe(Integer.MAX_VALUE); sink.emit(); source.readByte(); try { source.readIntLe(); fail(); } catch (EOFException expected) { } }
/** Write a little-endian 32-bit integer. */ public void writeFixed32(int value) throws IOException { sink.writeIntLe(value); }
private void writeFooter() throws IOException { sink.writeIntLe((int) crc.getValue()); // CRC of original data. sink.writeIntLe(deflater.getTotalIn()); // Length of original data. }
public void send(Packet packet) throws IOException { byte[] bytes; synchronized (lock) { int flags = PacketFlags.NONE; bytes = packet.encode(); byte[] compressed = GzipHelper.compress(bytes); if (compressed != null && compressed.length < bytes.length) { flags |= PacketFlags.COMPRESSED; bytes = compressed; } sink.writeIntLe(bytes.length); sink.writeIntLe(flags); sink.write(bytes); sink.emit(); } if (handler != null) { handler.onPacket(packet, bytes.length); } } }