private int crc(byte[] buf) { return crc(buf, 0, buf.length); }
private int crc(byte[] buf) { return crc(buf, 0, buf.length); }
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)); }
out.writeInt(crc(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 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)); }
out.writeInt(crc(b));
out.writeInt(crc(b));