javax.imageio.stream.IIOByteBuffer Java Examples

The following examples show how to use javax.imageio.stream.IIOByteBuffer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageInputStreamComparator.java    From sis with Apache License 2.0 5 votes vote down vote up
@Override
public void readBytes(final IIOByteBuffer dest, final int n) throws IOException {
    final IIOByteBuffer copy = new IIOByteBuffer(dest.getData().clone(), dest.getOffset(), dest.getLength());
    expected.readBytes(dest, n);
    actual  .readBytes(copy,   n);
    final int offset = dest.getOffset();
    final int length = dest.getLength();
    assertEquals("offset", offset, copy.getOffset());
    assertEquals("length", length, copy.getLength());
    assertArrayEquals(Arrays.copyOfRange(dest.getData(), offset, offset + length),
                      Arrays.copyOfRange(copy.getData(), offset, offset + length));
}
 
Example #2
Source File: MarkTryFinallyReproducer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void readBytes(IIOByteBuffer buf, int len) throws IOException {
    src.readBytes(buf, len);
}
 
Example #3
Source File: ChannelImageInputStream.java    From sis with Apache License 2.0 3 votes vote down vote up
/**
 * Reads up to {@code length} bytes from the stream, and modifies the supplied
 * {@code IIOByteBuffer} to indicate the byte array, offset, and length where
 * the data may be found.
 *
 * @param  dest    the buffer to be written to.
 * @param  length  the maximum number of bytes to read.
 * @throws IOException if an error occurred while reading.
 */
@Override
public final void readBytes(final IIOByteBuffer dest, int length) throws IOException {
    final byte[] data = new byte[length];
    length = read(data);
    dest.setData(data);
    dest.setOffset(0);
    dest.setLength(length);
}