mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-05 20:45:29 -04:00
Minimal readRaster implementation.
This commit is contained in:
parent
86fa76c17d
commit
b8a5bbe309
@ -129,8 +129,7 @@ public final class TIFFImageReader extends ImageReaderBase {
|
|||||||
// TODO: Tiling support (readTile, readTileRaster)
|
// TODO: Tiling support (readTile, readTileRaster)
|
||||||
// TODO: Implement readAsRenderedImage to allow tiled RenderedImage?
|
// TODO: Implement readAsRenderedImage to allow tiled RenderedImage?
|
||||||
// For some layouts, we could do reads super-fast with a memory mapped buffer.
|
// For some layouts, we could do reads super-fast with a memory mapped buffer.
|
||||||
// TODO: Implement readAsRaster directly (100% correctly)
|
// TODO: Implement readRaster directly (100% correctly)
|
||||||
// http://download.java.net/media/jai-imageio/javadoc/1.1/com/sun/media/imageio/plugins/tiff/package-summary.html#ImageMetadata
|
|
||||||
|
|
||||||
// TODOs Extension support
|
// TODOs Extension support
|
||||||
// TODO: Auto-rotate based on Orientation
|
// TODO: Auto-rotate based on Orientation
|
||||||
@ -144,6 +143,7 @@ public final class TIFFImageReader extends ImageReaderBase {
|
|||||||
// Source region
|
// Source region
|
||||||
// Subsampling
|
// Subsampling
|
||||||
// IIOMetadata (stay close to Sun's TIFF metadata)
|
// IIOMetadata (stay close to Sun's TIFF metadata)
|
||||||
|
// http://download.java.net/media/jai-imageio/javadoc/1.1/com/sun/media/imageio/plugins/tiff/package-summary.html#ImageMetadata
|
||||||
// Support ICCProfile
|
// Support ICCProfile
|
||||||
// Support PlanarConfiguration 2
|
// Support PlanarConfiguration 2
|
||||||
// Support Compression 3 & 4 (CCITT T.4 & T.6)
|
// Support Compression 3 & 4 (CCITT T.4 & T.6)
|
||||||
@ -2219,6 +2219,16 @@ public final class TIFFImageReader extends ImageReaderBase {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canReadRaster() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Raster readRaster(int imageIndex, ImageReadParam param) throws IOException {
|
||||||
|
return read(imageIndex, param).getData();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Tiling support
|
// TODO: Tiling support
|
||||||
// isImageTiled
|
// isImageTiled
|
||||||
// getTileWidth
|
// getTileWidth
|
||||||
|
@ -39,6 +39,7 @@ import javax.imageio.spi.ImageReaderSpi;
|
|||||||
import javax.imageio.stream.ImageInputStream;
|
import javax.imageio.stream.ImageInputStream;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.awt.image.Raster;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -630,4 +631,36 @@ public class TIFFImageReaderTest extends ImageReaderAbstractTest<TIFFImageReader
|
|||||||
assertEquals(ByteOrder.BIG_ENDIAN, streamMetadata.byteOrder);
|
assertEquals(ByteOrder.BIG_ENDIAN, streamMetadata.byteOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReadRaster() {
|
||||||
|
ImageReader reader = createReader();
|
||||||
|
|
||||||
|
for (TestData data : getTestData()) {
|
||||||
|
reader.setInput(data.getInputStream());
|
||||||
|
|
||||||
|
for (int i = 0; i < data.getImageCount(); i++) {
|
||||||
|
Raster raster = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
raster = reader.readRaster(i, null);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
failBecause(String.format("Image %s index %s could not be read: %s", data.getInput(), i, e), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertNotNull(String.format("Raster %s index %s was null!", data.getInput(), i), raster);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
String.format("Raster %s index %s has wrong width: %s", data.getInput(), i, raster.getWidth()),
|
||||||
|
data.getDimension(i).width,
|
||||||
|
raster.getWidth()
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
String.format("Raster %s index %s has wrong height: %s", data.getInput(), i, raster.getHeight()),
|
||||||
|
data.getDimension(i).height, raster.getHeight()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user