Fixed DCX off-by one issue + minor optimization.

This commit is contained in:
Harald Kuhr
2018-01-09 20:33:35 +01:00
parent 6113ae1c9c
commit 2a40bdb14b
4 changed files with 74 additions and 31 deletions

View File

@@ -29,13 +29,21 @@
package com.twelvemonkeys.imageio.plugins.dcx;
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTest;
import org.junit.Test;
import javax.imageio.ImageIO;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.stream.ImageInputStream;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* DCXImageReaderTest
*
@@ -82,4 +90,20 @@ public class DCXImageReaderTest extends ImageReaderAbstractTest<DCXImageReader>
"image/dcx", "image/x-dcx"
);
}
@Test
public void testCount() throws IOException {
try (ImageInputStream input = ImageIO.createImageInputStream(getClassLoaderResource("/dcx/input.dcx"))) {
DCXImageReader reader = createReader();
reader.setInput(input);
assertEquals(1, reader.getNumImages(true));
assertEquals(70, reader.getWidth(0));
assertEquals(46, reader.getHeight(0));
BufferedImage image = reader.read(0);
assertNotNull(image);
}
}
}