@Override public void saveVersion(Integer version) throws IOException { saveStream.writeInt(version); }
@Override public void saveVersion(Integer version) throws IOException { saveStream.writeInt(version); }
@Override public void saveReleaseVersion(String version) throws IOException { saveStream.writeInt(version.length()); saveStream.writeBytes(version); }
/** Write the atom length and type. */ private void writeAtom(int length, String type) throws IOException { out.writeInt(length); out.writeBytes(type); }
@Override public void saveRevision(String revision) throws IOException { saveStream.writeInt(revision.length()); saveStream.writeBytes(revision); }
/** Write the atom length and type. */ private void writeAtom(int length, String type) throws IOException { out.writeInt(length); out.writeBytes(type); }
@Override public void saveReleaseVersion(String version) throws IOException { saveStream.writeInt(version.length()); saveStream.writeBytes(version); }
@Override public void saveRevision(String revision) throws IOException { saveStream.writeInt(revision.length()); saveStream.writeBytes(revision); }
/** * Write the given value to the given RandomAccessOutputStream. * If the 'bigTiff' flag is set, then the value will be written as an 8 byte * long; otherwise, it will be written as a 4 byte integer. */ private void writeIntValue(RandomAccessOutputStream out, long offset) throws IOException { if (bigTiff) { out.writeLong(offset); } else { out.writeInt((int) offset); } }
/** * Write the given value to the given RandomAccessOutputStream. * If the 'bigTiff' flag is set, then the value will be written as an 8 byte * long; otherwise, it will be written as a 4 byte integer. */ private void writeIntValue(RandomAccessOutputStream out, long offset) throws IOException { if (bigTiff) { out.writeLong(offset); } else { out.writeInt((int) offset); } }
private void writeFooter() throws IOException { footerPointer = out.getFilePointer(); // write IEND chunk out.writeInt(0); out.writeBytes("IEND"); out.writeInt(crc("IEND".getBytes(Constants.ENCODING))); // update frame count out.seek(numFramesPointer); out.writeInt(numFrames); out.skipBytes(4); byte[] b = new byte[12]; b[0] = 'a'; b[1] = 'c'; b[2] = 'T'; b[3] = 'L'; DataTools.unpackBytes(numFrames, b, 4, 4, false); DataTools.unpackBytes(0, b, 8, 4, false); out.writeInt(crc(b)); }
private void writeFooter() throws IOException { footerPointer = out.getFilePointer(); // write IEND chunk out.writeInt(0); out.writeBytes("IEND"); out.writeInt(crc("IEND".getBytes(Constants.ENCODING))); // update frame count out.seek(numFramesPointer); out.writeInt(numFrames); out.skipBytes(4); byte[] b = new byte[12]; b[0] = 'a'; b[1] = 'c'; b[2] = 'T'; b[3] = 'L'; DataTools.unpackBytes(numFrames, b, 4, 4, false); DataTools.unpackBytes(0, b, 8, 4, false); out.writeInt(crc(b)); }
private void writePLTE() throws IOException { if (!(getColorModel() instanceof IndexColorModel)) return; IndexColorModel model = (IndexColorModel) getColorModel(); byte[][] lut = new byte[3][256]; model.getReds(lut[0]); model.getGreens(lut[1]); model.getBlues(lut[2]); out.writeInt(768); byte[] b = new byte[772]; b[0] = 'P'; b[1] = 'L'; b[2] = 'T'; b[3] = 'E'; for (int i=0; i<lut[0].length; i++) { for (int j=0; j<lut.length; j++) { b[i*lut.length + j + 4] = lut[j][i]; } } out.write(b); out.writeInt(crc(b)); }
private void writePLTE() throws IOException { if (!(getColorModel() instanceof IndexColorModel)) return; IndexColorModel model = (IndexColorModel) getColorModel(); byte[][] lut = new byte[3][256]; model.getReds(lut[0]); model.getGreens(lut[1]); model.getBlues(lut[2]); out.writeInt(768); byte[] b = new byte[772]; b[0] = 'P'; b[1] = 'L'; b[2] = 'T'; b[3] = 'E'; for (int i=0; i<lut[0].length; i++) { for (int j=0; j<lut.length; j++) { b[i*lut.length + j + 4] = lut[j][i]; } } out.write(b); out.writeInt(crc(b)); }
private void writeFCTL(int width, int height) throws IOException { out.writeInt(26); byte[] b = new byte[30]; b[0] = 'f'; b[1] = 'c'; b[2] = 'T'; b[3] = 'L'; DataTools.unpackBytes(nextSequenceNumber++, b, 4, 4, false); DataTools.unpackBytes(width, b, 8, 4, false); DataTools.unpackBytes(height, b, 12, 4, false); DataTools.unpackBytes(0, b, 16, 4, false); DataTools.unpackBytes(0, b, 20, 4, false); DataTools.unpackBytes(1, b, 24, 2, false); DataTools.unpackBytes(fps, b, 26, 2, false); b[28] = (byte) 1; b[29] = (byte) 0; out.write(b); out.writeInt(crc(b)); }
private void writeFCTL(int width, int height) throws IOException { out.writeInt(26); byte[] b = new byte[30]; b[0] = 'f'; b[1] = 'c'; b[2] = 'T'; b[3] = 'L'; DataTools.unpackBytes(nextSequenceNumber++, b, 4, 4, false); DataTools.unpackBytes(width, b, 8, 4, false); DataTools.unpackBytes(height, b, 12, 4, false); DataTools.unpackBytes(0, b, 16, 4, false); DataTools.unpackBytes(0, b, 20, 4, false); DataTools.unpackBytes(1, b, 24, 2, false); DataTools.unpackBytes(fps, b, 26, 2, false); b[28] = (byte) 1; b[29] = (byte) 0; out.write(b); out.writeInt(crc(b)); }
/** Writes the TIFF file header. */ public void writeHeader() throws IOException { // write endianness indicator out.seek(0); if (isLittleEndian()) { out.writeByte(TiffConstants.LITTLE); out.writeByte(TiffConstants.LITTLE); } else { out.writeByte(TiffConstants.BIG); out.writeByte(TiffConstants.BIG); } // write magic number if (bigTiff) { out.writeShort(TiffConstants.BIG_TIFF_MAGIC_NUMBER); } else out.writeShort(TiffConstants.MAGIC_NUMBER); // write the offset to the first IFD // for vanilla TIFFs, 8 is the offset to the first IFD // for BigTIFFs, 8 is the number of bytes in an offset if (bigTiff) { out.writeShort(8); out.writeShort(0); // write the offset to the first IFD for BigTIFF files out.writeLong(16); } else { out.writeInt(8); } }
/** Writes the TIFF file header. */ public void writeHeader() throws IOException { // write endianness indicator out.seek(0); if (isLittleEndian()) { out.writeByte(TiffConstants.LITTLE); out.writeByte(TiffConstants.LITTLE); } else { out.writeByte(TiffConstants.BIG); out.writeByte(TiffConstants.BIG); } // write magic number if (bigTiff) { out.writeShort(TiffConstants.BIG_TIFF_MAGIC_NUMBER); } else out.writeShort(TiffConstants.MAGIC_NUMBER); // write the offset to the first IFD // for vanilla TIFFs, 8 is the offset to the first IFD // for BigTIFFs, 8 is the number of bytes in an offset if (bigTiff) { out.writeShort(8); out.writeShort(0); // write the offset to the first IFD for BigTIFF files out.writeLong(16); } else { out.writeInt(8); } }