mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-05 04:25:29 -04:00
#431: Clean-up + added test
This commit is contained in:
parent
2235f6c911
commit
4afa934251
@ -70,9 +70,8 @@ public final class PICTImageReaderSpi extends ImageReaderSpiBase {
|
|||||||
// Skip header 512 bytes for file-based streams
|
// Skip header 512 bytes for file-based streams
|
||||||
stream.reset();
|
stream.reset();
|
||||||
|
|
||||||
// If we don't mark again here, the reset call in the finally block will:
|
// We need to set mark again, to make sure the reset call in
|
||||||
// A) do nothing
|
// the finally block will not consume existing marks
|
||||||
// B) eat marks created in the stream previously
|
|
||||||
stream.mark();
|
stream.mark();
|
||||||
|
|
||||||
skipNullHeader(stream);
|
skipNullHeader(stream);
|
||||||
@ -118,7 +117,7 @@ public final class PICTImageReaderSpi extends ImageReaderSpiBase {
|
|||||||
return (magic & 0xffff0000) == PICT.MAGIC_V1 || magic == PICT.MAGIC_V2;
|
return (magic & 0xffff0000) == PICT.MAGIC_V1 || magic == PICT.MAGIC_V2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageReader createReaderInstance(final Object pExtension) throws IOException {
|
public ImageReader createReaderInstance(final Object pExtension) {
|
||||||
return new PICTImageReader(this);
|
return new PICTImageReader(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import javax.imageio.spi.IIORegistry;
|
import javax.imageio.spi.IIORegistry;
|
||||||
import javax.imageio.spi.ImageReaderSpi;
|
import javax.imageio.spi.ImageReaderSpi;
|
||||||
|
import javax.imageio.stream.ImageInputStream;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -15,6 +16,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,6 +93,21 @@ public class PICTImageReaderTest extends ImageReaderAbstractTest<PICTImageReader
|
|||||||
super.testReadWithSubsampleParamPixels();
|
super.testReadWithSubsampleParamPixels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProviderShouldNotConsumeExistingMarks() throws IOException {
|
||||||
|
try (ImageInputStream stream = new ByteArrayImageInputStream(new byte[1024])) {
|
||||||
|
stream.seek(42);
|
||||||
|
stream.mark();
|
||||||
|
stream.seek(123);
|
||||||
|
|
||||||
|
sProvider.canDecodeInput(stream);
|
||||||
|
|
||||||
|
assertEquals(123, stream.getStreamPosition());
|
||||||
|
stream.reset();
|
||||||
|
assertEquals(42, stream.getStreamPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Regression tests
|
// Regression tests
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user