/** * Seek to the given (x, y) coordinate of the image that starts at * the given offset. */ protected void seekToPlaneOffset(long baseOffset, int x, int y) throws IOException { out.seek(baseOffset); MetadataRetrieve r = getMetadataRetrieve(); int samples = getSamplesPerPixel(); int pixelType = FormatTools.pixelTypeFromString(r.getPixelsType(series).toString()); int bpp = FormatTools.getBytesPerPixel(pixelType); if (interleaved) bpp *= samples; try { int sizeX = getSizeX(); out.skipBytes(bpp * (y * sizeX + x)); } catch (FormatException e) { throw new IOException(e); } }
/** * Seek to the given (x, y) coordinate of the image that starts at * the given offset. */ protected void seekToPlaneOffset(long baseOffset, int x, int y) throws IOException { out.seek(baseOffset); MetadataRetrieve r = getMetadataRetrieve(); int samples = getSamplesPerPixel(); int pixelType = FormatTools.pixelTypeFromString(r.getPixelsType(series).toString()); int bpp = FormatTools.getBytesPerPixel(pixelType); if (interleaved) bpp *= samples; try { int sizeX = getSizeX(); out.skipBytes(bpp * (y * sizeX + x)); } catch (FormatException e) { throw new IOException(e); } }
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)); }
pixels.skipBytes(bytesPerPixel * rgbChannels * sizeX * y); for (int row=0; row<h; row++) { ByteArrayOutputStream strip = new ByteArrayOutputStream(); pixels.skipBytes(bytesPerPixel * rgbChannels * x); pixels.write(strip.toByteArray()); pixels.skipBytes(bytesPerPixel * rgbChannels * (sizeX - w - x));
pixels.skipBytes(bytesPerPixel * rgbChannels * sizeX * y); for (int row=0; row<h; row++) { ByteArrayOutputStream strip = new ByteArrayOutputStream(); pixels.skipBytes(bytesPerPixel * rgbChannels * x); pixels.write(strip.toByteArray()); pixels.skipBytes(bytesPerPixel * rgbChannels * (sizeX - w - x));
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)); }