mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-10-06 12:40:22 -04:00
Fix SGI source subsampling + test optimizations.
This commit is contained in:
@@ -218,7 +218,8 @@ public final class SGIImageReader extends ImageReaderBase {
|
||||
|
||||
private void readRowByte(int height, Rectangle srcRegion, int[] scanlineOffsets, int[] scanlineLengths, int compression, int xSub, int ySub, int c, byte[] rowDataByte, WritableRaster destChannel, Raster srcChannel, int y) throws IOException {
|
||||
// If subsampled or outside source region, skip entire row
|
||||
if (y % ySub != 0 || height - 1 - y < srcRegion.y || height - 1 - y >= srcRegion.y + srcRegion.height) {
|
||||
int destY = height - 1 - y;
|
||||
if (destY % ySub != 0 || destY < srcRegion.y || destY >= srcRegion.y + srcRegion.height) {
|
||||
if (compression == SGI.COMPRESSION_NONE) {
|
||||
imageInput.skipBytes(rowDataByte.length);
|
||||
}
|
||||
@@ -245,16 +246,17 @@ public final class SGIImageReader extends ImageReaderBase {
|
||||
}
|
||||
}
|
||||
|
||||
normalize(rowDataByte, 9, srcRegion.width / xSub);
|
||||
normalize(rowDataByte, 0, srcRegion.width / xSub);
|
||||
|
||||
// Flip into position (SGI images are stored bottom/up)
|
||||
int dstY = (height - 1 - y - srcRegion.y) / ySub;
|
||||
int dstY = (destY - srcRegion.y) / ySub;
|
||||
destChannel.setDataElements(0, dstY, srcChannel);
|
||||
}
|
||||
|
||||
private void readRowUShort(int height, Rectangle srcRegion, int[] scanlineOffsets, int[] scanlineLengths, int compression, int xSub, int ySub, int c, short[] rowDataUShort, WritableRaster destChannel, Raster srcChannel, int y) throws IOException {
|
||||
// If subsampled or outside source region, skip entire row
|
||||
if (y % ySub != 0 || height - 1 - y < srcRegion.y || height - 1 - y >= srcRegion.y + srcRegion.height) {
|
||||
int destY = height - 1 - y;
|
||||
if (destY % ySub != 0 || destY < srcRegion.y || destY >= srcRegion.y + srcRegion.height) {
|
||||
if (compression == SGI.COMPRESSION_NONE) {
|
||||
imageInput.skipBytes(rowDataUShort.length * 2);
|
||||
}
|
||||
@@ -281,10 +283,10 @@ public final class SGIImageReader extends ImageReaderBase {
|
||||
}
|
||||
}
|
||||
|
||||
normalize(rowDataUShort, 9, srcRegion.width / xSub);
|
||||
normalize(rowDataUShort, 0, srcRegion.width / xSub);
|
||||
|
||||
// Flip into position (SGI images are stored bottom/up)
|
||||
int dstY = (height - 1 - y - srcRegion.y) / ySub;
|
||||
int dstY = (destY - srcRegion.y) / ySub;
|
||||
destChannel.setDataElements(0, dstY, srcChannel);
|
||||
}
|
||||
|
||||
|
@@ -53,7 +53,8 @@ public class SGIImageReaderTest extends ImageReaderAbstractTest<SGIImageReader>
|
||||
|
||||
@Override
|
||||
protected List<TestData> getTestData() {
|
||||
return Collections.singletonList(
|
||||
return Arrays.asList(
|
||||
new TestData(getClassLoaderResource("/sgi/input.sgi"), new Dimension(70, 46)), // RLE encoded RGB
|
||||
new TestData(getClassLoaderResource("/sgi/MARBLES.SGI"), new Dimension(1419, 1001)) // RLE encoded RGB
|
||||
);
|
||||
}
|
||||
|
BIN
imageio/imageio-sgi/src/test/resources/sgi/input.sgi
Normal file
BIN
imageio/imageio-sgi/src/test/resources/sgi/input.sgi
Normal file
Binary file not shown.
Reference in New Issue
Block a user