mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-05 04:25:29 -04:00
TMI-113: And fixed tests for JPEGSegmentInputStream to pass, as we now filter out App14/Adobe.
This commit is contained in:
parent
cd5b41be5b
commit
3ef93b6758
@ -136,9 +136,6 @@ final class JPEGSegmentImageInputStream extends ImageInputStreamImpl {
|
|||||||
// TODO: For progressive, there will be more than one SOS...
|
// TODO: For progressive, there will be more than one SOS...
|
||||||
length = Long.MAX_VALUE - realPosition;
|
length = Long.MAX_VALUE - realPosition;
|
||||||
}
|
}
|
||||||
// else if (marker == JPEG.APP14 && isAppSegmentWithId("Adobe", stream)) {
|
|
||||||
// length = 16;
|
|
||||||
// }
|
|
||||||
else {
|
else {
|
||||||
// Length including length field itself
|
// Length including length field itself
|
||||||
length = stream.readUnsignedShort() + 2;
|
length = stream.readUnsignedShort() + 2;
|
||||||
|
@ -111,15 +111,12 @@ public class JPEGSegmentImageInputStreamTest {
|
|||||||
ImageInputStream stream = new JPEGSegmentImageInputStream(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/no-image-types-rgb-us-web-coated-v2-ms-photogallery-exif.jpg")));
|
ImageInputStream stream = new JPEGSegmentImageInputStream(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/no-image-types-rgb-us-web-coated-v2-ms-photogallery-exif.jpg")));
|
||||||
List<JPEGSegment> appSegments = JPEGSegmentUtil.readSegments(stream, JPEGSegmentUtil.APP_SEGMENTS);
|
List<JPEGSegment> appSegments = JPEGSegmentUtil.readSegments(stream, JPEGSegmentUtil.APP_SEGMENTS);
|
||||||
|
|
||||||
assertEquals(2, appSegments.size());
|
assertEquals(1, appSegments.size());
|
||||||
|
|
||||||
assertEquals(JPEG.APP1, appSegments.get(0).marker());
|
assertEquals(JPEG.APP1, appSegments.get(0).marker());
|
||||||
assertEquals("Exif", appSegments.get(0).identifier());
|
assertEquals("Exif", appSegments.get(0).identifier());
|
||||||
|
|
||||||
assertEquals(JPEG.APP14, appSegments.get(1).marker());
|
// And thus, no JFIF, no Adobe, no XMP, no ICC_PROFILE or other segments
|
||||||
assertEquals("Adobe", appSegments.get(1).identifier());
|
|
||||||
|
|
||||||
// And thus, no JFIF, no XMP, no ICC_PROFILE or other segments
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -157,13 +154,12 @@ public class JPEGSegmentImageInputStreamTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testEOFExceptionInSegmentParsingShouldNotCreateBadState() throws IOException {
|
public void testEOFExceptionInSegmentParsingShouldNotCreateBadState() throws IOException {
|
||||||
ImageInputStream iis = new JPEGSegmentImageInputStream(ImageIO.createImageInputStream(getClassLoaderResource("/broken-jpeg/broken-no-sof-ascii-transfer-mode.jpg")));
|
ImageInputStream iis = new JPEGSegmentImageInputStream(ImageIO.createImageInputStream(getClassLoaderResource("/broken-jpeg/broken-no-sof-ascii-transfer-mode.jpg")));
|
||||||
int fileLength = 2021;
|
|
||||||
|
|
||||||
byte[] buffer = new byte[4096];
|
byte[] buffer = new byte[4096];
|
||||||
|
|
||||||
// NOTE: This is a simulation of how the native parts of com.sun...JPEGImageReader would read the image...
|
// NOTE: This is a simulation of how the native parts of com.sun...JPEGImageReader would read the image...
|
||||||
assertEquals(fileLength, iis.read(buffer, 0, buffer.length));
|
assertEquals(2, iis.read(buffer, 0, buffer.length));
|
||||||
assertEquals(fileLength, iis.getStreamPosition());
|
assertEquals(2, iis.getStreamPosition());
|
||||||
|
|
||||||
iis.seek(0x2012); // bad segment length, should have been 0x0012, not 0x2012
|
iis.seek(0x2012); // bad segment length, should have been 0x0012, not 0x2012
|
||||||
assertEquals(0x2012, iis.getStreamPosition());
|
assertEquals(0x2012, iis.getStreamPosition());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user